Triangles and their centres
A triangle has a great many notable points. The classical ones are here with exact coordinates, along with the circles and lines that go with them.
const t = triangle([0, 0], [4, 0], [1, 3]);
t.centroid; t.circumcenter; t.orthocenter; t.incenter; t.ninePointCenter; t.symmedian;
t.circumcircle; t.incircle; t.excircles.A; t.ninePointCircle;
t.eulerLine; t.medians.A; t.altitudes.B; t.bisectors.C;
t.area; t.sides; t.cosines; t.classify(); // { angles: "acute", sides: "scalene" }
t.barycentric(1, 2, 3); // any centre from its weights
Barycentric weights
Every point of the plane is a weighted average of the vertices, , and each classical centre has simple weights in terms of the side lengths a, b, c (opposite A, B, C):
| centre | weights | is where |
|---|---|---|
| centroid G | 1 : 1 : 1 | the medians meet |
| incentre I | a : b : c | the angle bisectors meet; centre of the inscribed circle |
| excentres | −a : b : c and so on | centres of the circles touching one side and two extensions |
| symmedian point | a² : b² : c² | the reflections of the medians in the bisectors meet |
The circumcentre O (perpendicular bisectors) and orthocentre H (altitudes) are found as intersections of lines. For a triangle with rational vertices G, O, H, the nine-point centre and the symmedian point are rational. The incentre is not in general, because the side lengths are square roots: for the triangle above each coordinate has degree 4 or 8 over the rationals and is printed in digits, but it is held exactly, which is how Feuerbach's theorem can be checked on it.
Measures
area is half the cross product, rational for rational vertices. sides are exact lengths and sides2 their squares. The angles are given by their cosines, which are exact algebraic numbers; degrees gives ordinary numbers for reading. classify() decides acute, right or obtuse from the sign of for the longest side, exactly, so a triangle is "right" only when it is.
The inradius is and the circumradius the radius of the circle through the vertices; Euler's relation connects them and can be tested with N.eq.
| property | value |
|---|---|
| A, B, C, vertices, sides, sides2, area, perimeter, cosines, degrees | the figure and its measures |
| centroid, circumcenter, orthocenter, incenter, excenters, ninePointCenter, symmedian, barycentric(u, v, w) | Points |
| circumcircle, incircle, excircles, ninePointCircle, circumradius, inradius | Circles and radii |
| medians, altitudes, bisectors, feet, eulerLine | Lines (by vertex) and Points |
| classify() | { angles, sides } |
@ratmath/geo and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.