Created
May 25, 2017 14:07
-
-
Save anonymous/cd8ef564513f24178a77967bccf0da29 to your computer and use it in GitHub Desktop.
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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Import CGA for a plane from clifford " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"This imports GA for basis $e_1,e_2,e_3, e_4$, where $e_{12}$ is original euclidean plane and $e_{34}$ is minkowski plane. `up()` and `down()` functions map vectors in and out of CGA. \n", | |
"\n", | |
"More info http://clifford.readthedocs.io/en/latest/ConformalGeometricAlgebra.html, " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 258, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"from clifford.g2c import * \n", | |
"from clifford import pretty\n", | |
"from numpy.random import rand\n", | |
"from scipy import e,pi,log\n", | |
"from math import atan \n", | |
"\n", | |
"pretty(precision=2)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Operators " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 260, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"# translation \n", | |
"T = lambda x: e**(1/2.*einf*x) \n", | |
"\n", | |
"# dilation \n", | |
"D = lambda alpha: e**(-log(alpha)/2.*(e34)) \n", | |
"\n", | |
"# rotation \n", | |
"R = lambda theta: e**(-theta/2.*e12)\n", | |
"\n", | |
"# vector transversion\n", | |
"#K = lambda x: e2*e**(eo*x) *e2\n", | |
"\n", | |
"# complex transversion (requires extra reflection for conjugation)\n", | |
"K = lambda x: e23*T(x)*e23" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Translation Example" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 261, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 261, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"V = T(2*e1) \n", | |
"\n", | |
"a = rand()*e1 + rand()*e2\n", | |
"A = up(a)\n", | |
"b = down(V*A*~V)\n", | |
"\n", | |
"b == a+2*e1" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Question " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Given an arbitrary conformal transformation, $V$" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 262, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"# random values of simple transformations\n", | |
"T_ = T(1*e1 + 2*e2)\n", | |
"D_ = D(.5)\n", | |
"R_ = R(pi/3)\n", | |
"K_ = K(3*e1 + 4*e2)\n", | |
"\n", | |
"V = T_*D_*R_*K_\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"How can i decompose $V$ into parameters of $T$, $D$, $R$, and $K$?" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Solution" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"The origin is only effected by the translation, so the translation parameter can be found by enacting $V$ on $e_o$, " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 263, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(1.0^e1) + (2.0^e2)" | |
] | |
}, | |
"execution_count": 263, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"t = down(V*eo*~V)\n", | |
"t" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"The parameter for $K$ can be found by using an operation we call *flipping*, denoted with an underline. It consists of reversing $V$ then reflecting it in $e_{14}$, \n", | |
"\n", | |
"$$\\underline{V} = e_{14}\\tilde{(T_tD_dR_rK_k)} e_{14} = T_{-k}D_dR_rK_{-t}$$\n", | |
"\n", | |
"This converts the transversion into a translation (proved in appendix), so the $k$ parameter can be found by operating on the origin, as before. " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 264, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(3.0^e1) + (4.0^e2)" | |
] | |
}, | |
"execution_count": 264, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"V_flip = e14*~V*e14\n", | |
"k = -down(V_flip*eo*~V_flip)\n", | |
"k " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Now that the parameters for $T$ and $K$ have been found, these can be removed form $V$, with \n", | |
"\n", | |
"$$\\tilde{T} V\\tilde{K}=DR$$\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 254, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"0.919 - (0.53^e12) + (0.306^e34) - (0.177^e1234)" | |
] | |
}, | |
"execution_count": 254, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"T_found = T(t)\n", | |
"K_found = K(k)\n", | |
"\n", | |
"DR = ~T_found * V * ~K_found\n", | |
"DR" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"$DR$ can be directly found by operating on any vector, choose $e_1$" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 255, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"dr = down(DR*up(e1)*~DR)\n", | |
"d = abs(dr)\n", | |
"r = atan((dr|e2)/(dr|e1))\n", | |
"\n", | |
"D_found = D(d)\n", | |
"R_found = R(r)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Verification of results " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 256, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"assert (T_found == T_)\n", | |
"assert (K_found == K_)\n", | |
"assert (D_found == D_)\n", | |
"assert (R_found == R_)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### Appendix: Flipping proof \n", | |
"The assertion of flipping opertor performating the following operation, \n", | |
"\n", | |
"$$\\underline{V} = e_{14}\\tilde{(T_tD_dR_rK_k)} e_{14} = T_{-k}D_dR_rK_{-t}$$\n", | |
"\n", | |
"can be proved by first reversing the individual Rotors in $V$. Then, noting that $e_{14}^2 =1$, we can insert pairs of $e_{14} $ in between each Rotor, allowing the net result to be computed one Rotor at a time. Working out the details for each rotor gives the results stated above, a verification is shown below.\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 243, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"x= 1*e1+2*e2\n", | |
"a = .5\n", | |
"\n", | |
"assert(e14*~K(x)*e14 == -T(-x))\n", | |
"assert(e14*~T(x)*e14 == -K(-x))\n", | |
"assert(e14*~D(a)*e14 ==D(a))\n", | |
"assert(e14*~R(a)*e14 ==R(a))" | |
] | |
} | |
], | |
"metadata": { | |
"anaconda-cloud": {}, | |
"kernelspec": { | |
"display_name": "Python [conda env:py27]", | |
"language": "python", | |
"name": "conda-env-py27-py" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.12" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment