sourcelibs/Manifold/demos/sphere.xtl
1⍝!/usr/bin/env xetal
2⍝ Manifold in use: three points on the unit sphere, their distances
3⍝ along it, a step and the arrow that undoes it, and their mean on the
4⍝ sphere beside the plain mean, which is not. Run with "just demo Manifold sphere".
5"mf:" u̲se< "Manifold"
6
7P ← 3 3 r̲eshape 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 ⍝ the three axes, one point per row
8p ← 1 s̲elect P
9q ← 2 s̲elect P
10
11p ᵐᶠs̲phereDistance q ⍝ a quarter turn, in radians
12ᵐᶠs̲phereDistances P ⍝ every pair
13
14v ← p ᵐᶠs̲phereArrow q ⍝ the arrow at p that reaches q
15v
16p ᵐᶠs̲phereStep v ⍝ the step along it: q, up to rounding
17p ᵐᶠs̲phereStep 0.5 × v ⍝ halfway there, still on the sphere
18ᵐᶠs̲phereOff p ᵐᶠs̲phereStep 0.5 × v
19
20m ← ('+ r̲/ P) ÷ 3.0 ⍝ the plain mean: inside the sphere
21m
22ᵐᶠs̲phereOff m
23ᵐᶠs̲phereMean P ⍝ the mean on the sphere
24ᵐᶠs̲phereOff ᵐᶠs̲phereMean P