3DCGA: Intersections

Based on https://enki.ws/ganja.js/examples/coffeeshop.html#cga3d_intersections.

First we create 3DCGA, and add its basis blades to the local namespace.

[1]:
from kingdon import Algebra

alg = Algebra(4, 1)
locals().update(alg.blades)

We start by defining a null basis, and upcasting for points

[2]:
ni = e4 + e5
no = 0.5 * (e5 - e4)
nino = ni ^ no
up = lambda x: no + x + 0.5 * x * x * ni

Next we’ll define some objects.

[3]:
p  = up(0)                          # point
S  = (p - 0.5 * ni).dual()                 # main dual sphere around point (interactive)
S2 = (up(-1.4*e1) - 0.125 * ni).dual()         # left dual sphere
C  = (up(1.4*e1) - 0.125 * ni).dual() & e3.dual()    # right circle
L  = up(0.9*e2) ^ up(0.9*e2 - 1*e1) ^ ni       # top line
P  = (1*e2 - 0.9*ni).dual()                   # bottom dual plane
P2 = (1*e1 + 1.7*ni).dual()                   # right dual plane
[4]:
C1 = S & P
C2 = S & L
C3 = S & S2
C4 = S & C
C5 = C & P2
lp = up(nino.lc(P2 & (L ^ no)))
[5]:
alg.graph(
    0x00FF0000, p, "s1",             # point
    0xFF00FF,lp,"l&p",               # line intersect plane
    0x0000FF,C1,"s&p",               # sphere meet plane
    0x888800,C2,"s&l",               # sphere meet line
    0x0088FF,C3,"s&s",               # sphere meet sphere
    0x008800,C4,"s&c",               # sphere meet circle
    0x880000,C5,"c&p",               # circle meet sphere
    0,L,0,C,                         # line and circle
    0xE0008800, P, P2,               # plane
    0xE0FFFFFF, S, "s1", S2,         # spheres
    conformal=1,
    grid=1,
    gl=1,
)
[5]:
[ ]: