Skip to content

Commit

Permalink
Update euler-angles.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-wieser authored Dec 17, 2021
1 parent e63f856 commit 8a4f028
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions docs/tutorials/euler-angles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
"2. rotate about the rotated $e_1$-axis, call it $e_1^{'}$\n",
"3. rotate about the twice rotated axis of $e_3$-axis, call it $e_3^{''}$\n",
"\n",
"So the elemental rotations are about $e_3, e_{1}^{'}, e_3^{''}$-axes, respectively.",
"\n",
"So the elemental rotations are about $e_3, e_{1}^{'}, e_3^{''}$-axes, respectively.\n",
"![](../_static/Euler2a.gif)\n",
"\n",
"(taken from wikipedia)"
Expand Down Expand Up @@ -217,7 +216,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The components of this frame **are** the rotation matrix, so we just enter the frame components into a matrix."
"The components of this frame **are** the rotation matrix, so we just enter the frame components as columns into a matrix."
]
},
{
Expand All @@ -226,19 +225,41 @@
"metadata": {},
"outputs": [],
"source": [
"from numpy import array \n",
"\n",
"M = [float(b|a) for b in B for a in A] # you need float() due to bug in clifford\n",
"M = array(M).reshape(3,3)\n",
"import numpy as np\n",
"\n",
"# b|a is a multivector, `[()]` selects the scalar part\n",
"M = np.array([\n",
" [(b|a)[()] for a in A]\n",
" for b in B\n",
"]) \n",
"M"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Thats a rotation matrix."
"That's a rotation matrix. We can compare transforming the vector $e_1 + 2e_2$ via the rotor and via the matrix:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"X = e1+2*e2\n",
"R*X*~R"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Xv = np.array([1, 2, 0])\n",
"M @ Xv"
]
},
{
Expand All @@ -252,9 +273,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In 3 Dimenions, there is a simple formula which can be used to directly transform a rotations matrix into a rotor.\n",
"In 3 Dimensions, there is a simple formula which can be used to directly transform a rotations matrix into a rotor.\n",
"For arbitrary dimensions you have to use a different algorithm (see `clifford.tools.orthoMat2Versor()` ([docs](../api/generated/clifford.tools.orthoMat2Versor.rst))).\n",
"Anyway, in 3 dimensions there is a closed form solution, as described in Sec. 4.3.3 of \"Geometric Algebra for Physicists\".\n",
"Anyway, in 3 dimensions there is a closed form solution, as described in Sec. 4.3.3 of <cite data-cite=\"doran-ga4ph\">Geometric Algebra for Physicists</cite>.\n",
"Given a rotor $R$ which transforms an orthonormal frame $A={a_k}$ into $B={b_k}$ as such,\n",
"\n",
"$$b_k = Ra_k\\tilde{R}$$\n",
Expand Down Expand Up @@ -324,7 +345,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.4"
"version": "3.7.10"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 8a4f028

Please sign in to comment.