This notebook is part of the clifford documentation: https://clifford.readthedocs.io/.

Object Oriented CGA

This is a shelled out demo for a object-oriented approach to CGA with clifford. The CGA object holds the original layout for an arbitrary geometric algebra , and the conformalized version. It provides up/down projections, as well as easy ways to generate objects and operators.

Quick Use Demo


In [ ]:
from clifford.cga import CGA, Round, Translation
from clifford import Cl

g3,blades = Cl(3)   

cga = CGA(g3)  # make cga from existing ga
# or 
cga = CGA(3)   # generate cga from dimension of 'base space'

locals().update(cga.blades)        # put ga's blades in local namespace

C = cga.round(e1,e2,e3,-e2)      # generate unit sphere from points 
C

In [ ]:
## Objects 
cga.round()              # from None 
cga.round(3)             # from dim of space
cga.round(e1,e2,e3,-e2)  # from points
cga.round(e1,e2,e3)      # from points
cga.round(e1,e2)         # from points
cga.round((e1,3))        # from center, radius
cga.round(cga.round().mv)# from existing multivector

cga.flat()               # from None 
cga.flat(2)              # from dim of space
cga.flat(e1,e2)          # from points
cga.flat(cga.flat().mv)  # from existing multivector


## Operations
cga.dilation()          # from from None 
cga.dilation(.4)        # from int
 
cga.translation()       # from None 
cga.translation(e1+e2)  # from vector  
cga.translation(cga.down(cga.null_vector()))

cga.rotation()          # from None
cga.rotation(e12+e23)   # from bivector 

cga.transversion(e1+e2).mv

In [ ]:
cga.round().inverted()

In [ ]:
D = cga.dilation(5)
cga.down(D(e1))

In [ ]:
C.mv # any CGA object/operator has a multivector

In [ ]:
C.center_down,C.radius # some properties of spheres

In [ ]:
T = cga.translation(e1+e2) # make a translation 
C_ = T(C)                  # translate the sphere 
cga.down(C_.center)        # compute center again

In [ ]:
cga.round()       #  no args == random sphere 
cga.translation() #             random translation

In [ ]:
if 1 in map(int, [1,2]):
    print(3)

Objects

Vectors


In [ ]:
a = cga.base_vector()  # random vector with components in base space only
a

In [ ]:
cga.up(a)

In [ ]:
cga.null_vector()  # create null vector directly

Sphere (point pair, circles)


In [ ]:
C = cga.round(e1, e2, -e1, e3) # generates sphere from points
C = cga.round(e1, e2, -e1)     # generates circle from points
C = cga.round(e1, e2)          # generates point-pair from points
#or 
C2 = cga.round(2)            # random 2-sphere  (sphere)
C1 = cga.round(1)            # random 1-sphere, (circle)
C0 = cga.round(0)            # random 0-sphere, (point pair)


C1.mv                        # access the multivector

In [ ]:
C = cga.round(e1, e2, -e1, e3)
C.center,C.radius        # spheres have properties

In [ ]:
cga.down(C.center) == C.center_down

In [ ]:
C_ = cga.round().from_center_radius(C.center,C.radius)
C_.center,C_.radius

Operators


In [ ]:
T = cga.translation(e1) # generate translation 
T.mv

In [ ]:
C = cga.round(e1, e2, -e1) 
T.mv*C.mv*~T.mv         # translate a sphere

In [ ]:
T(C)                # shorthand call, same as above. returns type of arg

In [ ]:
T(C).center

In [ ]:


In [ ]: