Practical Projective Geometric Algebra
Practical Projective Geometric Algebra
Geometric Algebra
Eric Lengyel, Ph.D.
l l c¢l
s¢t s¢l
b a l ¡a c
s ¢c
a s s
l t
c
a¡b s
p
a
p ¡a a s ¢d
g
s g
g l
c¡a c
g ¢c
l ¢g
s¢g s d
c
a
d ¡a
d s ¢p d
g
d c¢o o g
f p
d ¡p h g ¢d
p d ¡f g ¢h s
d c
s∗ ¡ a
a d g∗¡ l
p l
c s ¡c
∗
l d
g
c∗ ¡ p c l ∗¡ d
s g
g∗¡ d s
d
a a a
c
p c∗ ¡ a l
g ¡c
∗
p
g g
s
s ¡p
∗
l ¡p
∗
d∗ ¡ a
c
g ¡a∗
d g∗¡ p l
a d
a
p l
s c∗ ¡ d p
s ¡d
∗
s ¡l l ¡a
∗ ∗
s g
c p∗ ¡ a
Algebras
Projective
Geometric Algebra
Conformal
Geometric Algebra
Rigid
Geometric Algebra
Geometric Algebra
Exterior / Grassmann Algebra
Wedge product
• Combines dimensions that are present
• Add grades of operands
• Repeated vectors give zero:
a¡a 0
• Antisymmetric on vectors:
a¡b b¡a
Exterior / Grassmann Algebra
Duality means every product has an antiproduct
Antiwedge product ¢
• Combines dimensions that are absent
• Adds antigrades of operands
Geometric Algebra
Geometric product
• Includes wedge product
• Plus more information
• For vectors:
a ¥a a£a
• Duality means there is a geometric antiproduct ¦
Exterior / Geometric Algebra
Wedge and antiwedge products perform
geometric manipulation
• Join objects into higher-dimensional objects
• Intersect objects at lower-dimensional objects
• Project one object onto another object
p p x e1 p y e2 p z e3 pw e 4
p« p x e1 p y e2 p z e3
p¬ pw e 4
The Origin
The origin is a point with no bulk
• Homogeneous coordinates (0, 0, 0, w)
p pw e 4
Line
A 4D bivector is a line
• Grade 2
g« g w e 321
g¬ g x e 423 g y e 431 g z e 412
Points at Infinity
A point with zero weight is a point at infinity
• Can be interpreted as a direction vector
p p x e1 p y e2 p z e3
Lines at Infinity
A line with zero weight is a line at infinity
• Contains all points at infinity in directions parallel
to moment
g g w e 321
Bulk norm a «
a£a
Weight norm a ¬
a a
Reverses
There are two reverse operations
Generalization of conjugates
Norms
Duality
Duality
Every object is really two things at once
• One thing in space
• The dual of that thing in antispace
• Portals
• Occluders
• Shadow regions
• ...
Meet Operation
Line Crossing
Ray Passes Through Triangle
Check that ray passes on same side of all three edges
e1 ¥ e1 1 e1 ¦ e1 1
e2 ¥ e2 1 e2 ¦ e2 1
e3 ¥ e3 1 e3 ¦ e3 1
e4 ¥ e4 0 e4 ¦ e4 0
Geometric Product
Sandwiches with geometric product or antiproduct
perform transformations
F Fpx e1 Fpy e 2 Fpz e 3 Fpw e 4 Fgx e 423 Fgy e 431 Fgz e 412 Fgw e 321
Q ¦ p ¦ Q = (1 − 2Qvy2 − 2Qvz2 ) p x + 2(Qvx Qvy − Qvz Qvw ) p y + 2(Qvz Qvx + Qvy Qvw ) p z + 2(Qvy Qmz − Qvz Qmy + QvwQmx − Qvx Qmw ) pw e1
+ (1 − 2Qvz2 − 2Qvx2 )) p y + 2(Qvy Qvz − Qvx Qvw ) p z + 2(Qvx Qvy + Qvz Qvw ) p x + 2(Qvz Qmx − Qvx Qmz + QvwQmy − Qvy Qmw ) pw e 2
+ (1 − 2Qvx2 − 2Qvy2 )) p z + 2(Qvz Qvx − Qvy Qvw ) p x + 2(Qvy Qvz + Qvx Qvw ) p y + 2(Qvx Qmy − Qvy Qmx + QvwQmz − Qvz Qmw ) pw e 3
+ pw e 4
Q ¦ l ¦ Q = (1 − 2Qvy2 − 2Qvz2 )lvx + 2(Qvx Qvy − Qvz Qvw )lvy + 2(Qvz Qvx + Qvy Qvw )lvz e 41
+ (1 − 2Qvz2 − 2Qvx2 )lvy + 2(Qvy Qvz − Qvx Qvw )lvz + 2(Qvx Qvy + Qvz Qvw )lvx e 42
+ (1 − 2Qvx2 − 2Qvy2 )lvz + 2(Qvz Qvx − Qvy Qvw )lvx + 2(Qvy Qvz + Qvx Qvw )lvy e 43
+ −4(Qvy Qmy + Qvz Qmz )lvx + 2(Qvy Qmx + Qvx Qmy − Qvz Qmw − QvwQmz )lvy + 2(Qvz Qmx + Qvx Qmz + Qvy Qmw + QvwQmy )lvz + (1 − 2Qvy2 − 2Qvz2 )lmx + 2(Qvx Qvy − Qvz Qvw )lmy + 2(Qvz Qvx + Qvy Qvw )lmz e 23
+ −4(Qvz Qmz + Qvx Qmx )lvy + 2(Qvz Qmy + Qvy Qmz − Qvx Qmw − QvwQmx )lvz + 2(Qvx Qmy + Qvy Qmx + Qvz Qmw + QvwQmz )lvx + (1 − 2Qvz2 − 2Qvx2 )lmy + 2(Qvy Qvz − Qvx Qvw )lmz + 2(Qvx Qvy + Qvz Qvw )lmx e 31
+ −4(Qvx Qmx + Qvy Qmy )lvz + 2(Qvx Qmz + Qvz Qmx − Qvy Qmw − QvwQmy )lvx + 2(Qvy Qmz + Qvz Qmy + Qvx Qmw + QvwQmx )lvy + (1 − 2Qvx2 − 2Qvy2 )lmz + 2(Qvz Qvx − Qvy Qvw )lmx + 2(Qvy Qvz + 2Qvx Qvw )lmy e12
Q ¦ g ¦ Q = (1 − 2Qvy2 − 2Qvz2 ) g x + 2(Qvx Qvy − Qvz Qvw ) g y + 2(Qvz Qvx + Qvy Qvw ) g z e 423
+ (1 − 2Qvz2 − 2Qvx2 ) g y + 2(Qvy Qvz − Qvx Qvw ) g z + 2(Qvx Qvy + Qvz Qvw ) g x e 431
+ (1 − 2Qvx2 − 2Qvy2 ) g z + 2(Qvz Qvx − Qvy Qvw ) g x + 2(Qvy Qvz + Qvx Qvw ) g y e 412
+ [ 2(Qvy Qmz − Qvz Qmy + Qvx Qmw − QvwQmx ) g x + 2(Qvz Qmx − Qvx Qmz + Qvy Qmw − QvwQmy ) g y + 2(Qvx Qmy − Qvy Qmx + Qvz Qmw − QvwQmz ) g z + g w ] e 321
1 2(Qvy2 Qvz2 ) 2Qvx Qvy 2Qvz Qvx 2(Qvy Qmz Qvz Qmy )
2Qvx Qvy 1 2(Qvz2 Qvx2 ) 2Qvy Qvz 2(Qvz Qmx Qvx Qmz )
A
2Qvz Qvx 2Qvy Qvz 1 2(Qvx2 Qvy2 ) 2(QvxQmy Qvy Qmx )
0 0 0 1
Faster to compose
Inversion trivial
• It’s just the reverse
Interpolates nicer
De-orthogonalizes slower
Reciprocal Transformations
Sandwich with geometric antiproduct preserves horizon
e4 e+
−e + O
x
The
Horosphere
Origin and Infinity
Five basis elements
Origin = e 4
Infinity = e 5
Object Types in CGA
Round Object Real Imaginary
Round point a
Flat Object Representation
Flat point p
Dipole d
Line l
Circle c
Plane g
Sphere s
Joining
a
Points a ¡b ¡c
c¡
a
a¡ b
c
b¡ c
b
Flats
Round Point
Dipole
Circle
Sphere
Round and Flat Parts
Round part = all components without e5 factor
Radius norm: x ®
x x x x
Center norm: x x x x x
Reflected Reverse
Reflected reverse = x
car x x ¡ e5
acr x x ¡ e5
Carriers
Centers
Center is round point with same position and radius
cen x acr x ¢ x
Centers
Containers
Container is sphere with same center and radius
con x car x ¡ x
Containers
Partners
Partner is same round object with same center,
but real or imaginary radius is swapped
att x x ¢ e4
Attitude
Formula Illustration
Join
Dipole containing round points a and b.
b
a ¡ b = ( awbx − a x bw ) e 41 + ( a wb y − a y bw ) e 42 + ( a wbz − a z bw ) e 43
+ ( a y bz − a z b y ) e 23 + ( a z bx − a x bz ) e31 + ( a x b y − a y bx ) e12 a
+ ( a x bu − au bx ) e15 + ( a y bu − au b y ) e 25 a¡b
+ ( a z bu − au bz ) e35 + ( awbu − au bw ) e 45
d ¡ a = ( d vy a z − d vz a y + d mx a w ) e 423 + ( d vz a x − d vx a z + d my a w ) e 431
a
+ ( d vx a y − d vy a x + d mz a w ) e 412 − ( d mx a x + d my a y + d mz a z ) e321
d ¡a
+ ( d px a w − d pw a x + d vx au ) e 415 + ( d pz a y − d py a z + d mx au ) e 235
+ ( d py a w − d pw a y + d vy au ) e 425 + ( d px a z − d pz a x + d my au ) e315
d
+ ( d pz a w − d pw a z + d vz au ) e 435 + ( d py a x − d px a y + d mz au ) e125
d ¡ p = ( d vy p z − d vz p y + d mx p w ) e 4235 d ¡p
p
+ ( d vz p x − d vx p z + d my p w ) e 4315 d
+ ( d vx p y − d vy p x + d mz p w ) e 4125
− ( d mx p x + d my p y + d mz p z ) e 3215
Join
Formula Illustration
d ¡ f = − ( d vx f mx + d vy f my + d vz f mz + d mx f vx + d my f vy + d mz f vz ) e1234
d
+ ( d vy f pz − d vz f py + d pz f vy − d py f vz + d mx f pw + d pw f mx ) e 4235 f
+ ( d vz f px − d vx f pz + d px f vz − d pz f vx + d my f pw + d pw f my ) e 4315 d ¡f
+ ( d vx f py − d vy p px + d py f vx − d px f vy + d mz f pw + d pw f mz ) e 4125
− ( d mx f px + d my f py + d mz f pz + d px f mx + d py f my + d pz f mz ) e 3215
Formula Illustration
Meet
Circle where spheres s and t intersect.
s¢t
s ¢ t = ( su t x − s x tu ) e 423 + ( su t y − s y tu ) e 431
+ ( su t z − s z tu ) e 412 + ( su t w − swtu ) e321 s t
+ ( s z t y − s y t z ) e 415 + ( s x t z − s z t x ) e 425 + ( s y t x − s x t y ) e 435
+ ( s x t w − s wt x ) e 235 + ( s y t w − s wt y ) e315 + ( s z t w − s wt z ) e125
s ¢ c = ( s y c gz − s z c gy + su cvx ) e 41 + ( s w c gx − s x c gw + su cmx ) e 23
c
+ ( s z c gx − s x c gz + su cvy ) e 42 + ( s w c gy − s y c gw + su cmy ) e31 s ¢c
+ ( s x c gy − s y c gx + su cvz ) e 43 + ( s w c gz − s z c gw + su cmz ) e12
s
+ ( s z cmy − s y cmz + s w cvx ) e15 + ( s x cmz − s z cmx + s w cvy ) e 25
+ ( s y cmx − s x cmy + s w cvz ) e35 − ( s x cvx + s y cvy + s z cvz ) e 45
g ¢ c = ( g y c gz − g z c gy ) e 41 + ( g w c gx − g x c gw ) e 23 g
+ ( g z c gx − g x c gz ) e 42 + ( g w c gy − g y c gw ) e31 c
g ¢c
+ ( g x c gy − g y c gx ) e 43 + ( g w c gz − g z c gw ) e12
+ ( g z cmy − g y cmz + g w cvx ) e15 + ( g x cmz − g z cmx + g w cvy ) e 25
+ ( g y cmx − g x cmy + g w cvz ) e35 − ( g x cvx + g y cvy + g z cvz ) e 45
Meet Formula
s¢l
l
s ¢l = su lvx e 41 + su lvy e 42 + su lvz e 43
+ su lmx e 23 + su lmy e 31 + su lmz e12 s
+ ( s z lmy − s y lmz + s wlvx ) e15 + ( s x lmz − s z lmx + s wlvy ) e 25
+ ( s y lmx − s x lmy + s wlvz ) e35 − ( s x lvx + s y lvy + s z lvz ) e 45
s ¢d
s ¢ d = ( s y d mz − s z d my − s w d vx + su d px ) e1
+ ( s z d mx − s x d mz − s w d vy + su d py ) e 2
+ ( s x d my − s y d mx − s w d vz + su d pz ) e 3 s d
+ ( s x d vx + s y d vy + s z d vz + su d pw ) e 4
− ( s x d px + s y d py + s z d pz + s w d pw ) e 5
s∗ ¡ a = ( s x aw + su a x ) e 41 + ( s z a y − s y a z ) e 23
a
Illustration
s∗ ¡ a
+ ( s y a w + su a y ) e 42 + ( s x a z − s z a x ) e 31
+ ( s z a w + su a z ) e 43 + ( s y a x − s x a y ) e12
s
− ( s x au + s w a x ) e15 − ( s y au + s w a y ) e 25
− ( s z au + s w a z ) e 35 + ( su au − s w a w ) e 45
− ( g x au + g w a x ) e15 − ( g y au + g w a y ) e 25
g∗¡ a
− ( g z au + g w a z ) e 35 − g w aw e 45
g ∗ ¡ d = ( g y d vz − g z d vy ) e 423 + ( g z d vx − g x d vz ) e 431 d
+ ( g x d vy − g y d vx ) e 412 + ( g x d mx + g y d my + g z d mz ) e321 g
+ ( g x d pw + g w d vx ) e 415 + ( g z d py − g y d pz + g w d mx ) e 235
+ ( g y d pw + g w d vy ) e 425 + ( g x d pz − g z d px + g w d my ) e315
+ ( g z d pw + g w d vz ) e 435 + ( g y d px − g x d py + g w d mz ) e125
Formula Illustration
Connect
Line orthogonal to sphere s and containing flat point p.
p
s ¡ p = ( s x pw + su p x ) e 415 + ( s z p y − s y p z ) e 235
∗
+ ( s y p w + su p y ) e 425 + ( s x p z − s z p x ) e 315 s
s∗ ¡ p
+ ( s z p w + su p z ) e 435 + ( s y p x − s x p y ) e125
g ∗ ¡ p = g x pw e 415 + ( g z p y − g y p z ) e 235 p
+ g y pw e 425 + ( g x p z − g z p x ) e 315
g
+ g z pw e 435 + ( g y p x − g x p y ) e125
s∗ ¡ c = ( su c gw − s x c gx − s y c gy − s z c gz ) e1234 c s∗ ¡ c
+ ( s y cvz − s z cvy − s w c gx + su cmx ) e 4235
+ ( s z cvx − s x cvz − s w c gy + su cmy ) e 4315
+ ( s x cvy − s y cvx − s w c gz + su cmz ) e 4125 s
+ ( s x cmx + s y cmy + s z cmz − s w c gw ) e 3215
g ∗ ¡ c = − ( g x c gx + g y c gy + g z c gz ) e1234 c
+ ( g y cvz − g z cvy − g w c gx ) e 4235 g∗¡ c
g
+ ( g z cvx − g x cvz − g w c gy ) e 4315
+ ( g x cvy − g y cvx − g w c gz ) e 4125
+ ( g x cmx + g y cmy + g z cmz − g w c gw ) e 3215
c∗ ¡ a
+ ( c gx a y − c gy a x + cvz a w ) e 412 − ( cvx a x + cvy a y + cvz a z ) e321
+ ( cmx aw + c gw a x + c gx au ) e 415 + ( cmz a y − cmy a z + cvx au ) e 235
+ ( cmy aw + c gw a y + c gy au ) e 425 + ( cmx a z − cmz a x + cvy au ) e315 c
+ ( cmz aw + c gw a z + c gz au ) e 435 + ( cmy a x − cmx a y + cvz au ) e125
p∗ ¡ a
Projections
Same as rigid geometric algebra
Points
R2 > 0 R2 > 0
r2 > 0 r2 < 0
Contained
r R
Real Sphere
r
d d
by Sphere d 2 + r 2 = R2 R2 − r 2 = d 2
r2 < 0
r2 > 0 R2 < 0 R2 < 0
Imaginary Sphere
R
Impossible
d 2 − R 2 = −r 2
Points Contained by Sphere
Parametric Geometries
Generalization to non-scalar parameters
p u cen x u ¢ att x
Parametric Geometries
Dipole has scalar parameter
Circle has vector parameter
Sphere has bivector parameter
p u cen x u ¢ att x
Parametric Dipole
Sphere-Line Intersection
Calculate the points a and b where
a line l intersects a sphere having
center c and radius r. l
a b
c r
Are Two Circles Linked?
Given two arbitrarily oriented circles,
how can we tell if they are linked?
@EricLengyel