From 8a4f02853768e1b3cb1ec702dbeb7346a40da161 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Fri, 17 Dec 2021 01:29:52 +0000 Subject: [PATCH] Update euler-angles.ipynb --- docs/tutorials/euler-angles.ipynb | 43 +++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/docs/tutorials/euler-angles.ipynb b/docs/tutorials/euler-angles.ipynb index bb14667f..35748a99 100644 --- a/docs/tutorials/euler-angles.ipynb +++ b/docs/tutorials/euler-angles.ipynb @@ -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)" @@ -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." ] }, { @@ -226,11 +225,13 @@ "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" ] }, @@ -238,7 +239,27 @@ "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" ] }, { @@ -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 Geometric Algebra for Physicists.\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", @@ -324,7 +345,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.4" + "version": "3.7.10" } }, "nbformat": 4,