Skip to content

Commit

Permalink
structured doc
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenovic committed Sep 4, 2016
1 parent 44d1a01 commit 3572422
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 75 deletions.
74 changes: 1 addition & 73 deletions clifford/__init__.py
Original file line number Diff line number Diff line change
@@ -1,82 +1,9 @@
"""
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.
Quick Example
================
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
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
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) http://geocalc.clas.asu.edu/
API
------
Two classes, Layout and MultiVector, and several helper functions are
provided to implement the algebras.
Classes
===============
Expand Down Expand Up @@ -192,6 +119,7 @@
division. Public outcry will convince me to add the explicit casts
if this becomes a problem.
Acknowledgements
+++++++++++++++++
Konrad Hinsen fixed a few bugs in the conversion to numpy and adding some unit
Expand Down
58 changes: 58 additions & 0 deletions docs/G3.rst
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
Binary file added docs/_static/blades.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. automodule:: clifford
86 changes: 86 additions & 0 deletions docs/cga.rst
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...]
56 changes: 55 additions & 1 deletion docs/index.rst
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/










64 changes: 64 additions & 0 deletions docs/quickstart.rst
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`


2 changes: 1 addition & 1 deletion examples/Conformal Geometric Algebra.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
"version": "2.7.11"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 3572422

Please sign in to comment.