Topic

Transformations

An isometry of the plane is one of four things: a translation, a rotation, a reflection or a glide reflection. With exact matrices the classification is a computation, and composing two maps and asking what you got is the quickest way to learn it.

const r = rotation([1, 1], "1/4");               // a quarter turn about (1, 1)
String(r.apply([2, 1]));                         // "(1, 2)"
const m = reflection(line([0, 0], [1, 1]));
m.compose(reflection(line([0, 0], [1, 0]))).classify();   // a rotation by 90° about the origin
glide(line([0, 0], [1, 0]), [3, 0]).classify();  // { kind: "glide reflection", axis, vector }
dilation([0, 0], 2).compose(r).classify().kind;  // "spiral similarity"
inversion(circle([0, 0], { radius: 1 })).apply(line([2, 0], [2, 1]));   // a circle through the centre

Exact angles

A rotation matrix needs a cosine and a sine. Given as a fraction of a full turn, rotation(c, "1/6"), they are the exact algebraic values (12\tfrac12 and 32\tfrac{\sqrt3}{2} for a sixth of a turn). Or give any exact pair with cos⁡2+sin⁡2=1\cos^2 + \sin^2 = 1, such as { cos: "3/5", sin: "4/5" }, which is checked. Rotating by a sixth of a turn six times gives back exactly the identity.

Classifying

Every map here is p↦Mp+tp \mapsto Mp + t. classify() looks at M:

  • MTM=IM^{\mathsf T}M = I: an isometry. With determinant +1 it is a translation (M = I) or a rotation, whose centre is the one fixed point. With determinant −1 it is a reflection if it has a line of fixed points, and otherwise a glide reflection: a reflection followed by a slide along the mirror.
  • MTM=k2IM^{\mathsf T}M = k^2 I: a similarity with ratio k. It has exactly one fixed point, its centre: a dilation, a spiral similarity (dilation and rotation), or a dilative reflection.
  • otherwise an affine map: lines stay lines and parallels stay parallel, but angles change; the determinant is the factor by which areas are multiplied.

fixed() returns the fixed points: a point, a line, the whole plane or none.

Two facts worth trying: reflections in two lines that meet compose to a rotation about the meeting point through twice the angle between them, and in two parallel lines to a translation through twice the distance. So every isometry is a product of at most three reflections.

Inversion

Inversion in a circle with centre O and radius r sends p to the point p′ on the ray Op with ∣Op∣⋅∣Op′∣=r2|Op|\cdot|Op'| = r^2. It swaps inside and outside, fixes the circle, and sends lines and circles to lines and circles: a line through O to itself, a line missing O to a circle through O, and a circle through O to a line. inversion(c).apply(figure) returns the image exactly.

callreturns
translation(v), rotation(centre, turn | { cos, sin }), reflection(line), glide(line, v), dilation(centre, k), affine(M, t), identity()Transform
T.apply(point | line | circle | triangle | points)the image
T.compose(U), T.inverse(), T.equals(U), T.determinantT after U; the inverse
T.isIsometry(), T.isSimilarity(), T.fixed(), T.classify(){ kind, center, axis, vector, cos, sin, ratio, … }
inversion(circle).apply(point | line | circle)the image
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