triangule
v0.1.6
Published
a library for triangulation and other triangle calculations
Downloads
175
Maintainers
Readme
Triangule
Presentation
Triangule is a typescript library for computing angles and lengths of triangles.
It solves analytically common triangle problems in Euclidian geometry. It's based only on lengths and angles. On purpose, it doesn't use Cartesian coordinates.
It uses essentially the law of cosines and the law of sines.
Triangule relies on the standard library Math and doesn't have any extra dependency.
Links
- pkg : triangule as npm-package
- sources : git-repository
- API : public instance of the UI
- in use : public instance of the UI
Installation
npm install triangule
Usage
import { triAArA } from 'triangule';
const [a3, logstr] = triAArA(1.0, 2.0); // expect 0.14159
Development
git clone https://github.com/charlyoleg2/parame78
cd parame78
npm -w triangule install
npm -w triangule run ci
Main functions of Triangule
triAArA
Compute the third angle fron the two first angles. The sign of the two first angles must be identical. The sign of the third angle is the same as the sign of the two first angles. The sum of the 3 angles of a triangle is Pi.
triALArLL
From two angles and one length, compute the two remaining lengths. The two input angles must be adjacent to the input length. After getting the third angle, it uses the law of sines for computing the two remaining triangle-side-lengths.
triLALrL
From two lengths and one angle, compute the remaining length. The input angle must be the angle between the two lengths. It's the direct application of the law of cosines.
triALLrL
From one angle and two lengths, compute the two possible length of the third triangle-side. The input angle must be opposite to the second input length. It is the intersection between a line and a circle, which can have two solutions. The law of cosines provides an equation of the second degree, which can have two solutions.
triALLrLAA
Same inputs as triALLrL. The output is completed with two angles for each possible length.
triLLLrA
From the three lengths of a triangle, compute one of the angle. It's a direct application of the law of cosines.
triLLLrAAA
Same inputs as triLLLrA. The output is extended to the three angles of the triangle.
Common pitfalls around triangles
Oriented angles in a triangle
Either all angles of a triangle are positive or they are all negative.
Possible ways to measure an angle
- If we measure the angle between two half-lines, the angle is modulo 2*Pi.
- If we measure the angle between two lines, the angle is modulo Pi.
Let's note A, the angle between two lines. Those angles are equivalent:
- A
- A+Pi
- A-Pi
The following angles are not equivalent to A:
- -A
- Pi-A
- -Pi-A