programdemos/manifold-tour/manifold-tour.xtl
Manifold tour: five spaces this repository's experiments live on, the circle, the sphere, the torus, the Swiss roll and the Poincare disk, each drawn from its map (its own coordinates) into the space around it, and on each one measurement of what a manifold is: two points near each other are nearly as far apart along the space as through it (locally flat), two points far apart are not; on the roll, near through the air can be far along the sheet; on the disk, near the rim a small step on paper is a long way. Nothing is trained.
ᵘp̲airs : (Num a, Num b) => a -> b -> Float
a ᵘp̲airs b: a and b side by side, one (a, b) row per item (the
rows of a map). A general pairing belongs in X_eTaL-libraries: a
workaround here until it is asked for (docs/plan.md, G3b).
ᵘp̲airs ← { a b → o̲\ (2 c̲at t̲ally a) r̲eshape (f̲loat a) c̲at f̲loat b }
ᵘr̲ound : Int -> Float
ᵘr̲ound m: m + 1 angles evenly round a full turn, 0 to 2 pi, the
first repeated last: a closed wire line.
ᵘr̲ound ← { m → (2.0 × Pi ÷ f̲loat m) × (f̲loat r̲ange m + 1) − 1.0 }
ᵘe̲ach : Int -> a -> a
n ᵘe̲ach v: every item of v repeated n times, in v's order.
ᵘe̲ach ← { n v → r̲avel o̲\ (n c̲at t̲ally v) r̲eshape v }
ᵘt̲imes : Int -> a -> a
n ᵘt̲imes v: v whole, n times over.
ᵘt̲imes ← { n v → r̲avel (n c̲at t̲ally v) r̲eshape v }
ᵘl̲ength : Float -> Float
ᵘl̲ength M: the length of the wire line through the rows of M,
segment by segment (measured along the wire, not the curve).
ᵘl̲ength ← { M → '+ r̲/ s̲qrt '+ r̲/₂ ((1 d̲rop M) − -1 d̲rop M) ^ 2.0 }
ᵘs̲traight : (Num a, Num b) => a -> b -> Float
p ᵘs̲traight q: the straight-line distance, through whatever
surrounds the space.
ᵘs̲traight ← { p q → s̲qrt '+ r̲/ ((f̲loat p) − f̲loat q) ^ 2.0 }
ᵘt̲wo : Num a => a -> Float
ᵘt̲wo M: for the two points (rows) of M on the sphere or the
circle, the straight line through it and the distance along it.
ᵘt̲wo ← { M → ((1 s̲elect M) ᵘs̲traight 2 s̲elect M) c̲at (1 s̲elect M) ᵐᶠs̲phereDistance 2 s̲elect M }
ᵘl̲onLat : Num a => a -> Float
ᵘl̲onLat P: points of the sphere back onto its map, (longitude,
latitude) in degrees: where a drawn arc runs on the flat view.
ᵘl̲onLat ← { P → (((2 s̲elect₂ P) ᵗʳa̲tan2 1 s̲elect₂ P) ᵘp̲airs ᵗʳa̲sin 3 s̲elect₂ P) ÷ deg }
The circle: one dimension, drawn in two
circle : Float
circle ← ᵐᶠc̲irclePoints circleAngles
circleNearA : Float
Two points a tenth of a radian apart, and two 2.5 radians apart: the chord through the disk and the arc along the circle, for each.
circleNearA ← 0.0 0.1
circleNear : Float
circleNear ← ᵐᶠc̲irclePoints circleNearA
circleFar : Float
circleFar ← ᵐᶠc̲irclePoints circleFarA
circleNearD : Float
circleNearD ← ᵘt̲wo circleNear
circleFarD : Float
circleFarD ← ᵘt̲wo circleFar
The sphere: two dimensions, drawn in three
parallelLL : Float
The map's wire lines: five parallels (latitudes -60 to 60 degrees, 48 segments round) and twelve half meridians (every 30 degrees of longitude, pole to pole in 24 segments), as (longitude, latitude).
parallelLL ← (5 ᵘt̲imes ᵘr̲ound 48) ᵘp̲airs 49 ᵘe̲ach (30.0 × deg) × -2.0 -1.0 0.0 1.0 2.0
meridianLL : Float
meridianLL ← (25 ᵘe̲ach (30.0 × deg) × (f̲loat r̲ange 12) − 1.0) ᵘp̲airs 12 ᵘt̲imes (7.5 × deg) × (f̲loat r̲ange 25) − 13.0
parallels : Float
parallels ← ᵐᶠs̲pherePoints parallelLL
meridians : Float
meridians ← ᵐᶠs̲pherePoints meridianLL
sphereDeg : Float
Three points by longitude and latitude in degrees: p, q near it (6 degrees east, 3 north), r far from it; the chord through the sphere and the great circle along it, p to q and p to r; the arcs.
sphereDeg ← 3 2 r̲eshape 20.0 30.0 26.0 33.0 110.0 -35.0
spherePts : Float
spherePts ← ᵐᶠs̲pherePoints sphereLL
sphereNearD : Float
sphereNearD ← ᵘt̲wo 2 t̲ake spherePts
sphereNearArc : Float
sphereNearArc ← (1 s̲elect spherePts, 2 s̲elect spherePts) ᵐᶠs̲phereArc 12
sphereFarArc : Float
sphereFarArc ← (1 s̲elect spherePts, 3 s̲elect spherePts) ᵐᶠs̲phereArc 48
sphereNearArcLL : Float
sphereNearArcLL ← ᵘl̲onLat sphereNearArc
sphereFarArcLL : Float
sphereFarArcLL ← ᵘl̲onLat sphereFarArc
workedDiff : Float
The chord from p to q worked in full: the differences coordinate by coordinate, their squares, the sum (the chord is its square root); and the length of p + q, from which the great circle is 2 atan2(|p - q|, |p + q|).
workedDiff ← (1 s̲elect spherePts) − 2 s̲elect spherePts
workedSq : Float
workedSq ← workedDiff ^ 2.0
The torus: two dimensions, drawn in three, with a hole
radii : Float
radii ← 3.0 1.0
torusRingsUV : Float
Six rings round the hole (v every 60 degrees, 48 segments) and twelve round the tube (u every 30 degrees, 24 segments), as (u, v).
torusRingsUV ← (6 ᵘt̲imes ᵘr̲ound 48) ᵘp̲airs 49 ᵘe̲ach (60.0 × deg) × (f̲loat r̲ange 6) − 1.0
torusTubesUV : Float
torusTubesUV ← (25 ᵘe̲ach (30.0 × deg) × (f̲loat r̲ange 12) − 1.0) ᵘp̲airs 12 ᵘt̲imes ᵘr̲ound 24
torusRings : Float
torusRings ← radii ᵐᶠt̲orusPoints torusRingsUV
torusTubes : Float
torusTubes ← radii ᵐᶠt̲orusPoints torusTubesUV
torusRimLengths : Float
The outer ring (v = 0) and the inner ring (v = 180 degrees): the same line of the map, measured along the wire.
torusRimLengths ← (ᵘl̲ength 49 t̲ake torusRings) c̲at ᵘl̲ength 49 t̲ake 147 d̲rop torusRings
The Swiss roll: a flat sheet rolled up, in three dimensions
rollT : Float
The sheet: t from 1.5 pi to 4.5 pi (a turn and a half), h from -6 to 6. Five lines along the roll (60 segments) and thirteen across it (straight, 2 points), as (t, h); and the map they unroll to, (the length along the sheet, h).
rollT ← (1.5 × Pi) + (Pi ÷ 20.0) × (f̲loat r̲ange 61) − 1.0
rollAlongTH : Float
rollAlongTH ← (5 ᵘt̲imes rollT) ᵘp̲airs 61 ᵘe̲ach -6.0 -3.0 0.0 3.0 6.0
rollAcrossTH : Float
rollAcrossTH ← (2 ᵘe̲ach (1.5 × Pi) + (Pi ÷ 4.0) × (f̲loat r̲ange 13) − 1.0) ᵘp̲airs 13 ᵘt̲imes -6.0 6.0
rollAlong : Float
rollAlong ← ᵐᶠr̲ollPoints rollAlongTH
rollAcross : Float
rollAcross ← ᵐᶠr̲ollPoints rollAcrossTH
rollAlongMap : Float
rollAlongMap ← (ᵐᶠr̲ollAlong 1 s̲elect₂ rollAlongTH) ᵘp̲airs 2 s̲elect₂ rollAlongTH
rollAcrossMap : Float
rollAcrossMap ← (ᵐᶠr̲ollAlong 1 s̲elect₂ rollAcrossTH) ᵘp̲airs 2 s̲elect₂ rollAcrossTH
rollTH : Float
Three points of the sheet: a, b a little farther round, c one full turn farther round at the same height, so that it sits right above a's turn: through the air and along the sheet, a to b and a to c.
rollTH ← 3 2 r̲eshape (5.2 0.0 5.5 0.0) c̲at (5.2 + 2.0 × Pi) c̲at 0.0
rollPts : Float
rollPts ← ᵐᶠr̲ollPoints rollTH
rollNearD : Float
rollNearD ← ((1 s̲elect rollPts) ᵘs̲traight 2 s̲elect rollPts) c̲at (1 s̲elect rollTH) ᵐᶠr̲ollDistance 2 s̲elect rollTH
rollFarD : Float
rollFarD ← ((1 s̲elect rollPts) ᵘs̲traight 3 s̲elect rollPts) c̲at (1 s̲elect rollTH) ᵐᶠr̲ollDistance 3 s̲elect rollTH
The Poincare disk: two dimensions, flat on the page, with its own ruler
rim : Float
The rim (not part of the disk: points of the disk never reach it), and the disk's ruler laid along a diameter: the points 0, 1, 2, 3, 4 and 5 apart from the middle by the disk's distance.
rim ← ᵐᶠc̲irclePoints ᵘr̲ound 90
diskFar : Float
Two points near the rim, 20 degrees apart round it (at the top, off the ruler), and the same two drawn in toward the middle: on paper and by the disk's distance, for each; and the geodesics between them.
diskFar ← 0.95 × ᵐᶠc̲irclePoints deg × 80.0 100.0
diskNear : Float
diskNear ← 0.1 × ᵐᶠc̲irclePoints deg × 80.0 100.0
diskFarD : Float
diskFarD ← ((1 s̲elect diskFar) ᵘs̲traight 2 s̲elect diskFar) c̲at (1 s̲elect diskFar) ᵐᶠb̲allDistance 2 s̲elect diskFar
diskNearD : Float
diskNearD ← ((1 s̲elect diskNear) ᵘs̲traight 2 s̲elect diskNear) c̲at (1 s̲elect diskNear) ᵐᶠb̲allDistance 2 s̲elect diskNear
diskFarGeo : Float
diskFarGeo ← (1 s̲elect diskFar, 2 s̲elect diskFar) ᵐᶠb̲allGeodesic 24
diskNearGeo : Float
diskNearGeo ← (1 s̲elect diskNear, 2 s̲elect diskNear) ᵐᶠb̲allGeodesic 24
geo1 : Float
Three more geodesics, to see their shape: a diameter, and two arcs.
geo1 ← (-0.9 0.0, 0.9 0.0) ᵐᶠb̲allGeodesic 24
geo2 : Float
geo2 ← (-0.5 0.6, 0.7 0.2) ᵐᶠb̲allGeodesic 24
geo3 : Float
geo3 ← (0.0 -0.9, 0.6 -0.6) ᵐᶠb̲allGeodesic 24
The dimensions
dims : Float
Each space's intrinsic dimension (how many coordinates its map has: the circle's map is a list of angles, the others' are pairs) and its ambient dimension (how many coordinates the space it is drawn in has), read off the arrays' shapes: one row per space, the circle, the sphere, the torus, the roll, the disk.
dims ← ((t̲ally s̲hape circleAngles) c̲at (2 s̲elect s̲hape parallelLL) c̲at (2 s̲elect s̲hape torusRingsUV) c̲at (2 s̲elect s̲hape rollAlongMap) c̲at 2 s̲elect s̲hape rim) ᵘp̲airs (2 s̲elect s̲hape circle) c̲at (2 s̲elect s̲hape parallels) c̲at (2 s̲elect s̲hape torusRings) c̲at (2 s̲elect s̲hape rollAlong) c̲at 2 s̲elect s̲hape rim