Reference

Everything in the library

Every export of @ratmath/geo, with what it takes and what it returns. A point goes in as [x, y] or a Point; a coordinate is a whole number, a fraction or decimal string, a string such as "sqrt(3)/2", a Core Rational or an algebraic number. A JavaScript number that is not whole is refused.

Numbers

ExportWhat it does
num(x)An exact number from any of the forms above: a Rational when rational, otherwise an algebraic number.
NArithmetic on those numbers: add, sub, mul, div, neg, sq, sqrt, sign, isZero, cmp, eq, abs, min, max, sum, isRational, toNumber, text(a, digits), enclose(a, bits), cosPi(q), sinPi(q).
GeoErrorWhat the library throws, with a code: inexact, bad-number, bad-figure, division, sqrt and others.

Points, lines, circles

ExportWhat it does
point(x, y), PointA point. Methods: equals, plus, minus, times(k), toNumbers().
line(p, q), line(a, b, c), LineThe line through two points, or ax+by+c=0ax + by + c = 0. Methods: contains(p), at(p), equals; fields a, b, c, direction.
circle(centre, through), CircleThe circle with a centre through a point. Fields: center, radius, radius2. Methods: contains(p), power(p), equals.
distance(p, q), distance2(p, q), midpoint(p, q)Exact distance, its square, and the midpoint.
dot(u, v), cross(u, v), orientation(p, q, r)Products of vectors; +1 for a left turn, −1 for a right turn, 0 on a line.
collinear(...points), concyclic(...points)Exact tests.
parallel(l, m), perpendicular(l, m), concurrent(l, m, n)Exact tests on lines.
parallelThrough(l, p), perpendicularThrough(l, p), perpendicularBisector(p, q)Lines.
angleBisector(a, v, b, { external })The bisector of the angle at v.
foot(p, l), reflect(p, l)Foot of the perpendicular, and mirror image.
meet(f, g)The points common to two lines, a line and a circle, or two circles, as an array.
tangents(c, p), circumcircle(a, b, c)Tangent lines from a point; the circle through three points.
regularPolygon(n, { center, vertex })The vertices, exact for every n.
construction(given), ConstructionA recorded ruler-and-compass construction: line, circle, meet, get, count. See Constructions.

Measurement

namewhat it gives
angleSum(n), interiorAngle(n), exteriorAngle(n)(n − 2)·180, (n − 2)·180/n and 360/n, in degrees, exactly
line.slope, line.intercept, line.toSlopeIntercept(), line.toPointSlope(p)slope and intercept (null when vertical); "y = mx + b" and "y − y₀ = m(x − x₀)"
slopeIntercept(p, q), pointSlope(p, m){ slope, intercept, text, line } of the line through two points; the line through p with slope m
tangentLength(circle, p)√(power of p)
circleFromEquation(text | [A..F]), conicCoefficients(...)the circle by completing the square; the six coefficients of a conic
box(a, b, c), cylinder(r, h), cone(r, h), sphere(r)a box as a Polyhedron; the round solids' volume and areas as multiples of π
similar(k | { lengths | areas | volumes }){ scale, length, area, volume } ratios

Conic sections

namewhat it gives
conicProperties(text | [A, B, C, D, E, F]), conic.properties()type (degenerate kinds stop there); for an ellipse or hyperbola center, a, b, c, eccentricity, axes, vertices, coVertices, foci, directrices, asymptotes, standardForm; for a parabola vertex, focus, focalLength, axis, directrix, latusRectum

Vectors and planes in space

namewhat it gives
vector(x, y, z)dot, cross, norm, norm2, unit, angle, projectOnto, componentAlong, isParallel, isOrthogonal, add, sub, scale
tripleProduct(u, v, w)u·(v × w), the signed volume
line3(p, q), new Line3(point, direction)at(t), contains, distance
plane(p, q, r), plane(p, { normal }), plane({ coefficients })equation, coefficients, contains, distance, foot, angle, meet (a line or a plane), isParallel

Triangles

Member of triangle(a, b, c)What it is
sides, sides2, area, perimeter, cosines, degrees, classify()Measurements. Side a is opposite vertex A.
centroid, circumcenter, orthocenter, incenter, excenters, ninePointCenter, symmedianCentres. See Triangle centres.
barycentric(u, v, w)The point with those weights on A, B, C.
circumcircle, incircle, excircles, ninePointCircle, inradius, circumradiusCircles.
medians, altitudes, feet, bisectors, eulerLineLines and feet of altitudes.

Transformations

ExportWhat it does
identity(), translation(v), rotation(centre, turn), reflection(l), glide(l, v), dilation(centre, k), affine(matrix, vector)A Transform. A rotation's turn is a fraction of a full turn, as a string.
Transformapply(figure), compose(other), inverse(), equals, determinant, isSimilarity(), isIsometry(), fixed(), classify().
inversion(c)Inversion in a circle: apply to a point, a line or a circle.

Checked theorems

theorems.…Takes
pythagoras, eulerLine, ninePointCircle, feuerbach, napoleon, concurrency, herona triangle
ceva, menelausa triangle and points D, E, F on BC, CA, AB
simsona triangle and a point
ptolemy, varignonfour points
thalesa circle and three points on it
powerOfPointa circle, a point and two lines through it
pentagonnothing

Each returns { theorem, statement, holds } and the quantities it compared. See Checked theorems.

General proofs

NameWhat it is
configuration(name)A figure in coordinates, to state a theorem about. Its methods make points, give the polynomials of geometric properties, and prove.
T.at(name, x, y), T.free(name), T.parameter(name)A point with given coordinates (numbers, parameter names, or expressions); a point with two free coordinates; a free number.
T.on(name, P => condition, { free }), T.where(name, P => [c1, c2]), T.unknown(name, v => condition)A point with one free coordinate and one condition; a point fixed by two conditions; a number fixed by an equation.
T.midpoint, intersection, foot, reflection, parallelogram, circumcenter, orthocenter, centroid, tritangentCenter, onLine, onCircumcircle, otherIntersectionConstructions. Lines are pairs of points: T.intersection("P", [A, B], [C, D]).
T.collinear, parallel, perpendicular, equidistant, equalLength, onCircle, concyclic, concurrent, rightAngle, equalAngle, tangent, isMidpoint, equalPredicates: the polynomial (GeoExpr) that vanishes when the property holds.
T.distance2, area2, dot, cross, number; e.add, sub, mul, neg, powQuantities, and arithmetic on expressions.
T.prove(conclusion, { method, timeLimit, maxPairs, instance })A Proof. method is "wu", "groebner" or "auto". A list of conclusions gives a Proof with parts.
T.instance(conclusion), T.describe(), T.parameters, T.unknowns, T.hypotheses, T.pointsOne figure tried: { parameters, solutions, holdsAt }; the figure as text; the variables and hypotheses.
proof.proved, proof.method, proof.replay()Whether an identity was found and multiplied out; by which method; multiply it out again.
proof.identity{ ring, multiplier, power, cofactors, hypotheses, conclusion } with multiplier · conclusion^power = Σ cofactors[i] · hypotheses[i], as polynomials of @ratmath/structures.
proof.conditionsThe degenerate cases: [{ polynomial, text, meaning }]. The proof covers every figure at which none vanishes.
proof.explain({ cofactors }), proof.parts, proof.instance, proof.size, proof.msThe proof as text; one proof per conclusion; the figure tried when not proved; size of the certificate; time taken.
provable, proofs.<id>(options), proofs.all(options), proofs.setup(id)The classical theorems proved in general: thales, pythagoras, isosceles, midline, medians, altitudes, bisectors, eulerLine, ninePointCircle, orthocentreReflection, tritangent, varignon, parallelogram, inscribedAngle, chords, simson, butterfly, pappus, desargues, gaussLine, napoleon.

See General proofs.

Discrete and other geometries

ExportWhat it does
convexHull(points)The hull, counter-clockwise, without points inside edges.
onSegment(a, b, p), segmentIntersection(a, b, c, d)An exact test, and { meets, kind, point }: kind is "none", "cross", "touch" or "overlap" (then with from and to).
polygon(vertices), Polygonarea, signedArea, perimeter, centroid, edges, isConvex(), isSimple(), locate(p), contains(p), triangulate(), clip(convex).
inCircle(a, b, c, d)The sign of d against the circle through a, b, c.
delaunay(points), voronoi(points){ points, triangles, edges, cocircular } and { points, vertices, cells, edges, cocircular }. See Computational geometry.
closestPair(points){ points, distance2, distance }.
latticePointsOn(p, q), pick(vertices), isVisible(x, y), visiblePoints(n)See Lattice geometry.
metric(name)"taxicab", "chebyshev" or "euclidean": distance, circle, pi, bisector, ellipse. See Taxicab geometry.
planThe phases still to come, each { phase, contents, estimate }.

Projective and finite geometry

ExportWhat it does
ppoint, pline, lineAtInfinity, PPoint, PLinePoints and lines in homogeneous coordinates; dual swaps them. See The projective plane.
join, meetLines, collinearP, concurrentPIncidence, exactly.
crossRatio, harmonicConjugateThe projective invariant of four collinear points.
projectivity(matrix), projectivityFrom(from, to), ProjectivityProjective maps: apply, compose, inverse, isAffine.
conicThrough(points), ConicConics: contains, polar, pole, tangentAt, transform, classify.
desargues, pappus, pascal, brianchonThe classical theorems checked on a figure.
projectivePlane(q), affinePlane(q), fano(), incidence(lines)Finite planes and incidence structures: axioms, designParameters, parallels, completion, collineations, collineationGroup. See Finite geometries.

The sphere and the hyperbolic plane

ExportWhat it does
angle(x), Angle, turnsOfCos(c), piTimes(k)Angles with exact cosine and sine; turns is the fraction of a full turn or null, decided exactly; value(digits) encloses the radians. See Spherical geometry.
LengthA hyperbolic length by its exact cosh and sinh: exp, text, value(digits), add, double, half.
spoint, latLon, fromStereographic, northPole, SPointPoints of the unit sphere: antipode, distanceTo, latLon, stereographic.
greatCircle(P, Q), equator(), GreatCirclecontains, poles, meet, angleWith, perpendicularThrough, distanceTo, reflection, parallelsThrough.
striangle(A, B, C), STriangle, lunesides, angles, excess, area, fractionOfSphere, polar, classify(), checks().
scircle(centre, through), SCircleradius, circumference and area as multiples of π.
srotation(axis, turns), antipodalMap(), SIsometryapply, then, inverse, classify(): rotation, reflection or rotary reflection.
hpoint(x, y), fromKlein, fromHalfPlane, fromHyperboloid, horigin, HPointA point of the hyperbolic plane: disc, klein, halfPlane, hyperboloid, distanceTo. See The hyperbolic plane.
ideal(x, y), HIdealA point at infinity.
hline(a, b), hbisector, hmidpoint, HLineends, disc, klein, halfPlane, distanceTo, foot, perpendicularThrough, relation, reflection, parallelsThrough.
hcircle(centre, through), horocycle(ideal, p), HCircleradius, circumference, area, and the Euclidean circle in the disc.
htriangle(A, B, C), HTrianglesides, angles, defect, area, checks(); vertices may be ideal. See Hyperbolic triangles, motions, tilings.
hreflection, hrotation, hhalfTurn, htranslation, HIsometryapply, then, inverse, classify(), toMobius().
schlafli(p, q), hyperbolicTiling(p, q)The regular tiling {p, q}: its geometry and exact tile; a patch of tiles.
parallelPostulate({ q })Playfair's postulate counted in five geometries. See The parallel postulate.
hyperbolicFigure(items, { model }), hyperbolicTilingFigure(p, q, { layers, model })Figures in the Poincaré disc, the Klein disc or the half-plane.

Topology

ExportWhat it does
surface(word or [words]), SurfaceGlued polygons: cells, eulerCharacteristic, orientable, boundaryComponents, boundaryMatrices, chainComplex(), homology(k, { coefficients }), betti(), classify(), fundamentalGroup(), singleFace(), connectedSum(S). See Surfaces from polygons.
classifySurface({ euler, orientable, boundaryComponents }){ genus or crosscaps, name, normalForm } by the classification theorem.
parseEdgeWord(text), formatEdgeWord(tokens)Edge words such as "a b a^-1 b^-1" as { label, exp } tokens and back.
simplicialComplex(simplices), SimplicialComplex, simplicialfaces(k), fVector, eulerCharacteristic, boundary(k), chainComplex(), homology, betti, link(v), components(), isSurface, surfaceCheck(), classify(), fundamentalGroup(); simplicial.simplex, sphere, torus, projectivePlane, kleinBottle, fromGraph, fromPolyhedron. See Simplicial complexes.
finiteSpace(points, opens), fromBasis, fromPreorder, finiteSpacesFiniteSpace: opens, closedSets, closure, interior, boundary, minimalOpen, specialization, isT0, isT1, components, continuity(f, Y), subspace. See Finite spaces.
countTopologies(n, { t0 }), allTopologies(points)Topologies on n ≤ 5 points through preorders; every topology on up to 4 points.

Solids, symmetry and tilings

ExportWhat it does
polyhedron(points), Polyhedron, solids, prism(n)Convex polyhedra with proved faces: euler, volume, surfaceArea, dihedralCosines, dual, symmetry. See Polyhedra.
figureSymmetry(points)The rosette group Cₙ or Dₙ of a finite figure. See Symmetry groups.
friezeGroup({ points, period }), friezesOne of the seven frieze groups.
wallpaperGroup({ gram, points }), wallpaperOne of the seventeen wallpaper groups, with the flowchart's steps; patterns for each.
polygonAngle, vertexTypes, uniformTiling, regularTilingsTilings by regular polygons. See Tilings.
Try itEdit the code and run it with @ratmath/geo and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs