Skip to main content

Finds the remaining sides and angles of a triangle when given enough of the sides and/or angles. Includes a command line exerciser, formatting tools, and a test suite.

Project description

planetriangles

Mostly you will use:

err_msg, a, b, c, A, B, C = complete_the_triangle(a, b, c, A, B, C)

This is the main routine in the plane_triangles.py module. Its input parameters default to None.

It solves (if possible) for the missing sides and/or angles in the parameter list.

If two solutions are possible, it will indicate this by a return value in err_msg that starts with “Other”. The first answer should be used, then a request made for the return of the second by repeating the original call with the ssa_flag set to 'other', i.e.

err_msg, a, b, c, A, B, C = complete_the_triangle(a, b, c, A, B, C, ssa_flag=’other’)

Installation

pip install planetriangles

Then, to get started, from a python REPL you can run the exerciser with …

>>> from planetriangles.exerciser import run_ui
>>> run_ui()

Load the user functions with …

>>> from planetriangles.plane_triangles import *

All of the exported functions have help text included. So you can get help with the usual help(complete_the_triangle) method. There are a number of formatting routines for converting angles to various forms (radians, degrees, degrees and minutes, degrees minutes seconds) with a specified precision.

The module (plane_triangles_tests.py) contains a set of tests. It uses assert statements to detect errors. Importing the module will run the tests. All is well when no assert throws an exception.

There is an interactive test/excercise program that can be invoked by importing and executing run_ui() from the module excerciser.py. To get it started, do this …

>>> from planetriangles.exerciser import run_ui
>>> run_ui()

It starts with a prompt that allow one to set the desired format for the display of angles (radians, degrees, degrees and minutes, degrees and minutes and seconds).

The next two prompts allow the precision (number of digits to right of decimal point) for angles and lengths to be specified.

A loop is then entered that prompts for the sides and angles to be used. Just press enter to indicate that a value will not be provided (i.e., is to be calculated).

If all six parameters are left empty, the loop terminates.

Example

>>> from planetriangles.exerciser import run_ui()
>>> run_ui()
.
Session started...
.
Angle format to use [r, d, dm, dms]: d
Angle precision (digits to right of decimal point) to use: 4
Length precision (digits to right of decimal point) to use: 4
.
Side a: 1
Side b: 1
Side c:
Angle A (degrees):
Angle B (degrees):
Angle C (degrees): 90
a: 1.0000 b: 1.0000 c: 1.4142   A: 45.0000d B: 45.0000d C: 90.0000d

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

planetriangles-1.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file planetriangles-1.1-py3-none-any.whl.

File metadata

  • Download URL: planetriangles-1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4

File hashes

Hashes for planetriangles-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a64537ea52aa31e27510b53c554f793c21b922b582a6a3628c2a17791c7700f5
MD5 5c1dcf02f5c6fe10fe0edd4431cdd16c
BLAKE2b-256 ef8152c24e4d60ba5e566153cd819049dad63331baa52d8ff9490d39bd7b01eb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page