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.
npm install triangule
import { triAArA } from 'triangule';
const [a3, logstr] = triAArA(1.0, 2.0); // expect 0.14159
git clone https://github.com/charlyoleg2/parame78
cd parame78
npm -w triangule install
npm -w triangule run ci
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.
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.
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.
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.
Same inputs as triALLrL. The output is completed with two angles for each possible length.
From the three lengths of a triangle, compute one of the angle. It's a direct application of the law of cosines.
Same inputs as triLLLrA. The output is extended to the three angles of the triangle.
Either all angles of a triangle are positive or they are all negative.
Let's note A, the angle between two lines. Those angles are equivalent:
The following angles are not equivalent to A: