Created
June 23, 2018 14:09
-
-
Save arsenovic/40ff7e7a0e60abbf2f0eba9ff9b14e03 to your computer and use it in GitHub Desktop.
This file contains hidden or 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": [ | |
"# Cartan's Rotation Algorithms" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from clifford import eps\n", | |
"from clifford.tools import orthoFrames2Verser\n", | |
"from clifford.tools.g3c import * \n", | |
"from scipy import e,rand" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 131, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"works\n" | |
] | |
} | |
], | |
"source": [ | |
"subspace = e123 # can change to e12 to test g2 operations\n", | |
"\n", | |
"def generate_rotation_rotor():\n", | |
" B = subspace.project(random_bivector())\n", | |
" return e**B\n", | |
"\n", | |
"def generate_translation_rotor():\n", | |
" a = subspace.project(layout.randomV())\n", | |
" return (1 + ninf *a / 2)\n", | |
"\n", | |
"# generates random vectors in g3\n", | |
"euc_vector = lambda: subspace.project(layout.randomV())\n", | |
"\n", | |
"# Create random euclidean transformation from translations and rotation\n", | |
"T = generate_translation_rotor()\n", | |
"R = generate_rotation_rotor()\n", | |
"D = generate_dilation_rotor(rand())\n", | |
"V = T*R*D\n", | |
"\n", | |
"\n", | |
"a = [euc_vector() for k in range(4)] # create set of 4 vectors\n", | |
"A = list(map(up,a)) #\n", | |
"# homo() ==down/up roundtrip. observations are in g3, not g3c, so \n", | |
"# this is represented by doing a down/up round trip, which is just homo()\n", | |
"B = [homo(V*k*~V) for k in A] \n", | |
"\n", | |
"V_found,rs = orthoFrames2Verser(A=A,B=B, remove_scaling=True,det=1)\n", | |
"\n", | |
"if (min( abs(V_found+V),abs(V_found-V)) <eps() ):\n", | |
" print('works')\n", | |
"else:\n", | |
" print('fails')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 132, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(-0.99714 - (0.02005^e12) + (0.09564^e13) - (0.24437^e14) - (0.24437^e15) - (0.03431^e23) + (0.55138^e24) + (0.55138^e25) - (0.67557^e34) - (0.67557^e35) - (0.0704^e45) + (0.03089^e1234) + (0.03089^e1235) - (0.00142^e1245) + (0.00675^e1345) - (0.00242^e2345),\n", | |
" 0.99714 + (0.02005^e12) - (0.09564^e13) + (0.24437^e14) + (0.24437^e15) + (0.03431^e23) - (0.55138^e24) - (0.55138^e25) + (0.67557^e34) + (0.67557^e35) + (0.0704^e45) - (0.03089^e1234) - (0.03089^e1235) + (0.00142^e1245) - (0.00675^e1345) + (0.00242^e2345))" | |
] | |
}, | |
"execution_count": 132, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"V_found,V" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 133, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"100 loops, best of 3: 5.31 ms per loop\n" | |
] | |
} | |
], | |
"source": [ | |
"%%timeit\n", | |
"orthoFrames2Verser(A=A,B=B, remove_scaling=True,det=1)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"anaconda-cloud": {}, | |
"kernelspec": { | |
"display_name": "Python [default]", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.2" | |
}, | |
"toc": { | |
"nav_menu": {}, | |
"number_sections": true, | |
"sideBar": true, | |
"skip_h1_title": false, | |
"toc_cell": false, | |
"toc_position": {}, | |
"toc_section_display": "block", | |
"toc_window_display": false | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment