-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
266 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
.. g3: | ||
The Geometry of Space (G3) | ||
========================== | ||
|
||
Instantiate a G3 algebra | ||
|
||
.. ipython:: | ||
|
||
In [138]:import clifford as cf | ||
|
||
In [138]:cf.pretty(precision=2) # sets display precision | ||
|
||
In [138]:layout, blades = cf.Cl(3) # creates a 2-dimensional clifford algebra | ||
|
||
|
||
Inspect Blades | ||
|
||
.. ipython:: | ||
|
||
In [138]: blades | ||
|
||
Assign Blades | ||
|
||
.. ipython:: | ||
|
||
In [138]: e0,e1,e2 = [blades['e'+k] for k in '012'] | ||
|
||
In [138]: e01 = e0*e1 | ||
|
||
In [138]: e12 = e1*e2 | ||
|
||
In [138]: e02 = e0*e2 | ||
|
||
In [138]: e012 = e0*e1*e2 | ||
|
||
|
||
|
||
|
||
Rotations | ||
|
||
.. ipython:: | ||
|
||
In [138]: from scipy.constants import e,pi | ||
|
||
In [138]: R0 = e**(pi/4 *e01) | ||
In [138]: R1 = e**(pi/4 *e12) | ||
In [138]: R = R1*R0 | ||
|
||
In [138]: R*e0*~R | ||
|
||
Rotations dont commute | ||
|
||
.. ipython:: | ||
|
||
In [138]: R0*R1 == R1*R0 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. automodule:: clifford |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
.. cga: | ||
Conformal Geometric Algerba (CGA) | ||
==================================== | ||
|
||
Intro | ||
-------- | ||
|
||
Conformal Geometric Algebra (CGA) is a projective geometry tool that linearizes the conformal group. | ||
|
||
[ explain minkowski basis] | ||
|
||
Mapping | ||
-------- | ||
Vectors in the orignal space are mapped to vectors in conformal space through the map: | ||
|
||
.. math:: | ||
X = x + \frac{1}{2} x^2 e_{\infty} +e_o | ||
The inverse map is the made by normalizing the conformal vector, then rejection from the minkowski plane $E_0$, | ||
|
||
|
||
.. math:: | ||
X = \frac{X}{X \cdot e_{\infty}} | ||
then | ||
|
||
.. math :: | ||
x = X \wedge E_0\, E_0^{-1} | ||
Implement it | ||
------------- | ||
.. ipython:: | ||
|
||
In [138]: import clifford as cf | ||
|
||
In [138]: cf.pretty(precision=2) | ||
|
||
In [138]: layout, blades = cf.Cl(3,1, firstIdx=1) | ||
|
||
|
||
Create an orthonormal basis, and a null basis | ||
|
||
.. ipython:: | ||
|
||
In [138]: e1,e2,e3,e4 = [blades['e%i'%k] for k in range(1,5)] | ||
|
||
In [138]: eo = .5^(e4-e3) | ||
|
||
In [138]: einf= e3+e4 | ||
|
||
In [138]: E0= einf^eo | ||
|
||
In [138]: I = e1^e2^e3^e4 | ||
|
||
|
||
Define the up and down projection functions | ||
|
||
.. ipython:: | ||
|
||
In [138]: up = lambda x: x + (.5^((x**2)*einf)) + eo | ||
|
||
In [138]: homo = lambda x: x * (-x|einf).normalInv() # homogenise conformal vector | ||
|
||
In [138]: down = lambda x: (homo(x)^E0)|E0 | ||
|
||
|
||
|
||
.. ipython:: | ||
|
||
|
||
In [138]: v4 = lambda : cf.randomMV(layout, grades=[1]) | ||
|
||
In [138]: def v2(): | ||
|
||
x=v4() | ||
|
||
return x- E0.project(x) | ||
|
||
|
||
[ Do things...] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,56 @@ | ||
.. automodule:: clifford | ||
|
||
clifford: Geometric Algebra for Python | ||
======================================= | ||
|
||
|
||
|
||
This module implements geometric algebras (a.k.a. Clifford algebras). For the | ||
uninitiated, a geometric algebra is an algebra of vectors of given dimensions | ||
and signature. The familiar inner (dot) product and the outer product, | ||
a generalized relative of the three-dimensional cross product, are unified in an | ||
invertible geometric product. Scalars, vectors, and higher-grade entities can | ||
be mixed freely and consistently in the form of mixed-grade multivectors. | ||
|
||
|
||
.. image:: _static/blades.png | ||
:width: 500 px | ||
:align: center | ||
|
||
|
||
Documentation | ||
------------------ | ||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
quickstart | ||
G3 | ||
cga | ||
|
||
API | ||
------ | ||
|
||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
api | ||
|
||
|
||
Links | ||
-------- | ||
|
||
* Symbolic geometric alebra module for python: https://github.com/brombo/galgebra | ||
|
||
* Cambridge GA group: http://www.mrao.cam.ac.uk/~clifford | ||
|
||
* David Hestenes' (The man) website: http://geocalc.clas.asu.edu/ | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
.. _quickstart: | ||
QuickStart (G2) | ||
================ | ||
|
||
Instantiate a G2 algebra | ||
|
||
.. ipython:: | ||
|
||
In [138]:import clifford as cf | ||
|
||
In [138]:cf.pretty(precision=2) # sets display precision | ||
|
||
In [138]:layout, blades = cf.Cl(2) # creates a 2-dimensional clifford algebra | ||
|
||
Inspect Blades | ||
|
||
.. ipython:: | ||
|
||
In [138]: blades | ||
|
||
Assign Blades | ||
|
||
.. ipython:: | ||
|
||
In [138]: e0 = blades['e0'] | ||
|
||
In [138]: e1 = blades['e1'] | ||
|
||
In [138]: e01 = blades['e01'] | ||
|
||
|
||
Basics | ||
|
||
.. ipython:: | ||
|
||
In [4]:e0*e1 # geometric product | ||
|
||
In [5]:e0^e1 # outer product | ||
|
||
In [6]:e0|e1 # inner product | ||
|
||
Rotation | ||
|
||
.. ipython:: | ||
|
||
In [138]: from scipy.constants import e,pi | ||
|
||
In [138]: R = e**(pi/4 *e01) | ||
In [138]: R*e0*~R | ||
|
||
|
||
Reflection | ||
|
||
.. ipython:: | ||
|
||
In [138]: a = e0+e1 | ||
|
||
In [138]: n = e1 | ||
|
||
In [138]: -n*a*n # reflect in hyperplane normal to `n` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters