Simple Python package that can be used to do calculations with right-angled triangles.
Installation
Use pip to install right-triangle.
pip install right-triangle
Usage
The RightTriangle class
A RightTriangle instance is a representation of a right-angled triangle.
It has 6 attributes:
side_a - first leg, the length of the side opposed to angle_a
side_b - second leg, the length of the side opposed to angle_b
side_c - the length of the hypotenuse of the triangle
angle_a - first acute angle, the angle opposed to side_a, measured in degrees
angle_b - second acute angle, the angle opposed to side_b, measured in degrees
angle_c - the right angle, always 90 degrees
You can instantiate a RightTriangle with one of the following information:
The lengths of any two sides of the triangle
One angle (in degrees) and the length of one side of the triangle
You can use either a specialised factory method (.from_*) or the universal one (.make) to construct an instance.
During the instantiation the other attributes are calculated and become accessible.
>>> from right_triangle import RightTriangle
>>> rt1 = RightTriangle.from_side_a_and_side_b(3, 4)
>>> rt2 = RightTriangle.make(side_a=3, side_b=4)
>>> rt1.side_c
5.0
>>> rt2.side_c
5.0
Functions
The module also provides some functions. You can use them to calculate some attributes of a right triangle without actually instantiating a RightTriangle object.
>>> import right_triangle
>>> right_triangle.calculate_hypotenuse_from_legs(3, 4)
5.0
>>> right_triangle.calculate_acute_angles_from_legs(3, 4)
(36.86989764584402, 53.13010235415598)
>>> right_triangle.calculate_leg_from_other_leg_and_hypotenuse(3, 5)
4.0
>>> right_triangle.calculate_leg_from_hypotenuse_and_opposed_angle(5, 36.8699)
3.000000164351089
>>> right_triangle.calculate_leg_from_other_leg_and_adjacent_angle(4, 53.1301)
3.000000256798589
Metadata
Release files for right-triangle 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| right-triangle-0.2.0.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| right_triangle-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.9 kB
Release files / right-triangle-0.2.0.tar.gz
| Download URL | right-triangle-0.2.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8df9111639d15791b4b862e12c1c48956c41093bc9fdfb7963d7cd39f496f065
|
|
BLAKE2b-256 checksum How to use checksums |
b70b19a684a8b782c6728df6869be84afc12f81a466a27c96cfadc61dd1264d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6
|
Release files / right_triangle-0.2.0-py3-none-any.whl
| Download URL | right_triangle-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
06a2ebb304dd82b7c2126bdac3055937fc910611d4f2545aa868fce34ab8ff42
|
|
BLAKE2b-256 checksum How to use checksums |
f5ab93f2a01b0358f8abfbf03ff975ef8390211c4980f9ebd336744485df9e13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6
|