The hyperbolic plane
In the hyperbolic plane, through a point off a line there are infinitely many lines that never meet it. The plane cannot be drawn in ours without distortion, so it is drawn in models, each wrong in a different way. Here a point is one exact object and the models are four views of it.
const p = hpoint("1/2", 0); // coordinates in the Poincaré disc
p.klein; p.halfPlane; p.hyperboloid; // (4/5, 0) (0, 3) [5/3, 4/3, 0]
horigin().distanceTo(p).text; // "ln(3)"
const l = hline(["1/2", 0], [0, "1/2"]);
String(l.disc); // "circle, centre (5/4, 5/4), radius √34/4"
String(l.klein); // "5·x + 5·y - 4 = 0": a straight chord
const axis = hline(ideal(-1, 0), ideal(1, 0));
axis.parallelsThrough([0, "1/2"]).angle; // the angle of parallelism, cosine 4/5
Four models, one point
The model that makes the algebra simple is the hyperboloid: the points with and . With the form
it behaves like a sphere of radius : the distance is given by , a line is for a vector , and the isometries are the matrices that keep . The library keeps every point there. The other three are views:
- The Poincaré disc, . Angles are true to the eye; lines are arcs of circles that meet the boundary at right angles, or diameters.
- The Klein disc, . Lines are straight chords, so incidence looks Euclidean; angles are distorted.
- The half-plane, the Poincaré disc under . Lines are half-circles centred on the real axis, or vertical lines.
The maps between the hyperboloid, the Poincaré disc and the half-plane are rational, so a point with rational coordinates in one has them in the others: (½, 0) in the disc is (0, 3) in the half-plane and (5/3, 4/3, 0) on the hyperboloid. Going to and from the Klein disc needs one square root in one direction. hpoint(x, y) takes Poincaré disc coordinates; fromKlein, fromHalfPlane and fromHyperboloid take the others; and every point has .disc, .klein, .halfPlane and .hyperboloid.
The boundary circle is not part of the plane. Its points are the ideal points, the directions in which a line can leave: ideal(x, y), or ideal("1/8") at an angle given as a fraction of a turn.
Distance
A distance is a Length. It holds and exactly, so is an exact algebraic number and the distance is its logarithm: from the centre of the disc to (½, 0) is exactly , and value(digits) encloses it. Lengths add exactly, by the addition formulas for cosh and sinh. Near the boundary the disc's scale shrinks without limit: the point at Euclidean radius is at distance from the centre.
Lines, and three ways for two of them to lie
Through two points there is one line, hline(a, b); either point may be ideal. A line has two ends, and its shape in each model is available as an exact circle or line of the plane.
For two lines with normals , compare with . relation reports which case holds:
- intersecting (less): they cross in one point, at an angle with exact cosine;
- asymptotic (equal): they share an end and come arbitrarily close without meeting;
- ultraparallel (more): they have exactly one common perpendicular, and its length, the shortest distance between them, has .
Parallels and the angle of parallelism
Take a line and a point at distance from it. The two lines from to the ends of the line are the limiting parallels. Every line through between them misses the given line, so there are infinitely many parallels. The limiting ones make an angle with the perpendicular from , the angle of parallelism, and Lobachevsky's formula for it becomes an exact statement about a cosine:
As the angle tends to a right angle, the Euclidean answer; as grows it tends to 0. At distance it is exactly 60°, and parallelsThrough returns it as the angle π/3. See the parallel postulate for the same question in every geometry of the package.
Circles and horocycles
A circle of radius has circumference and area , both more than in the plane and growing exponentially. They are exact multiples of π: the circle of radius has circumference and area . In the Poincaré disc a hyperbolic circle is a Euclidean circle, but its centre is somewhere else; circle.disc gives it. A horocycle is the limit of circles through a point as the centre goes off to an ideal point: in the disc, a circle touching the boundary.
| call | returns |
|---|---|
| hpoint(x, y), fromKlein, fromHalfPlane, fromHyperboloid, horigin() | HPoint: disc, klein, halfPlane, hyperboloid, distanceTo |
| ideal(x, y), ideal(turns) | HIdeal: disc, halfPlane (a number, or null for the point at infinity) |
| hline(a, b), hbisector(a, b), hmidpoint(a, b) | HLine: contains, side, ends, disc, klein, halfPlane, distanceTo, foot, perpendicularThrough, relation, meets, reflection, parallelsThrough |
| hcircle(centre, point | { cosh } | { exp }), horocycle(ideal, p) | HCircle: radius, circumference, area, disc, contains |
| Length.ofCosh(c), Length.ofExp(e), Length.ofSinh(s) | Length: cosh, sinh, exp, tanh, text, value(digits), add, double, half, equals |
| hyperbolicFigure(items, { model }) | A figure in the Poincaré disc, the Klein disc or the half-plane |
@ratmath/geo and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.