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
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')
All of the exported functions (it’s ok to use plane_triangles import *) 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. 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for planetriangles-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7700a91017f6f6b1ac99ff2766e4ad8593c0a7d76141037d1cb01a710b004cee |
|
MD5 | b307d59056ba22956548792cf265aef8 |
|
BLAKE2b-256 | 77e9356c5c505f182228363d66f2ad6ff92acb4df708dbe4a619ae4b9055e6bd |