<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>FloCal</title>
    <link>https://herding.github.io/</link>
    <description>Recent content on FloCal</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language><atom:link href="https://herding.github.io/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Angle Axis</title>
      <link>https://herding.github.io/posts/angle_axis/</link>
      <pubDate>Sat, 06 Jun 2026 11:24:20 +0800</pubDate>
      
      <guid>https://herding.github.io/posts/angle_axis/</guid>
      <description>&lt;p&gt;Rotation about the $x$-axis is a special case of a three-dimensional rotation. It can be expressed with Euler angles, but it is also naturally represented by a single angle $\theta$ and a rotation axis $\mathbf u = [1, 0, 0]^T \in \mathbb R^3$. This form is known as the angle-axis representation, where the rotation vector $\phi = \theta \mathbf u$ encodes both the axis direction and the rotation magnitude. Note that the axis vector is assumed to be normalized, $||\mathbf u|| = 1$.&lt;/p&gt;
&lt;p&gt;This post explores the relationship between a rotation matrix and the angle-axis representation. First, we derive the rotation matrix for the simple case of rotation about the $x$-axis, and then generalize the result to an arbitrary unit axis $\mathbf u$ and angle $\theta$. We also show how the angle-axis can be recovered from a given rotation matrix.&lt;/p&gt;
&lt;h2 id=&#34;from-the-angle-axis-to-rotation-matrix&#34;&gt;From the angle-axis to rotation matrix&lt;/h2&gt;
&lt;p&gt;In this section, we derive a rotation matrix from the angle-axis representation. We start with the simple case of rotation about the $x$-axis, then extend the derivation to an arbitrary rotation axis and angle.&lt;/p&gt;
&lt;h3 id=&#34;a-simple-case&#34;&gt;a simple case&lt;/h3&gt;
&lt;p&gt;In the simple case, $x$-axis is a rotation direction with magnitude $\theta$, new unit vectors after rotation are expressed as
&lt;/p&gt;
$$
\begin{aligned} \mathbf e_{x&#39;} &amp;= \begin{bmatrix}1&amp; 0&amp; 0\end{bmatrix}^T \\ \mathbf e_{y&#39;} &amp; = \begin{bmatrix}0&amp; \cos \theta&amp; \sin \theta\end{bmatrix}^T \\ \mathbf e_{z&#39;} &amp;= \begin{bmatrix}0&amp; -\sin \theta&amp; \cos \theta\end{bmatrix}^T \end{aligned}
$$&lt;p&gt;
Furthermore, these unit vectors are derived from original unit vectors, $\mathbf e_x, \mathbf e_y$ and $\mathbf e_z$,
&lt;/p&gt;
$$
\begin{aligned} \begin{bmatrix} \mathbf e_{x&#39;} \\ \mathbf e_{y&#39;} \\ \mathbf e_{z&#39;} \end{bmatrix}^T &amp;= \begin{bmatrix} 1 \cdot \mathbf e_x + 0 \cdot \mathbf e_y + 0 \cdot \mathbf e_z \\ 0 \cdot \mathbf e_x + \cos\theta \cdot \mathbf e_y + \sin \theta \cdot \mathbf e_z \\ 0 \cdot \mathbf e_x - \sin \theta \cdot \mathbf e_y + \cos \theta \cdot \mathbf e_z \end{bmatrix}^T \\ &amp;= \begin{bmatrix}\mathbf e_x&amp; \mathbf e_y&amp; \mathbf e_z\end{bmatrix}\begin{bmatrix}1&amp; 0 &amp; 0 \\0&amp; \cos \theta &amp; -\sin \theta \\0&amp; \sin \theta &amp; \cos \theta\end{bmatrix} \end{aligned}
$$&lt;p&gt;
where $[\mathbf e_x\quad \mathbf e_y\quad \mathbf e_z]$ is an identity matrix.&lt;/p&gt;
&lt;p&gt;Although the above equations already give the rotation matrix, there is another way to obtain it: multiply $[\mathbf e_{x&amp;rsquo;}, \mathbf e_{y&amp;rsquo;}, \mathbf e_{z&amp;rsquo;}]$ by $[\mathbf e_x, \mathbf e_y, \mathbf e_z]^T$, that is,
&lt;/p&gt;
$$
\begin{aligned}
\begin{bmatrix}
\mathbf e_{x&#39;}&amp; \mathbf e_{y&#39;}&amp; \mathbf e_{z&#39;}
\end{bmatrix} \begin{bmatrix}
\mathbf e_{x}^T\\ \mathbf e_{y}^T \\ \mathbf e_{z}^T
\end{bmatrix} &amp;= \begin{bmatrix}\mathbf e_x&amp; \cos\theta\mathbf e_y + \sin \theta \mathbf e_z&amp; -\sin\theta \mathbf e_y + \cos\theta \mathbf e_z\end{bmatrix}\begin{bmatrix}
\mathbf e_{x}^T\\ \mathbf e_{y}^T \\ \mathbf e_{z}^T
\end{bmatrix}\\
&amp;= \mathbf e_x\mathbf e_x^T + \cos\theta \mathbf e_y\mathbf e^T_y + \sin\theta\mathbf e_z\mathbf e^T_y -\sin \theta\mathbf e_y \mathbf e^T_z + \cos\theta \mathbf e_z\mathbf e^T_z \\
&amp;= \begin{bmatrix}1\\0\\0\end{bmatrix}\begin{bmatrix}1&amp;0&amp;0\end{bmatrix} + \cos\theta \mathbf e_y\mathbf e^T_y + \sin\theta\mathbf e_z\mathbf e^T_y -\sin \theta\mathbf e_y \mathbf e^T_z + \cos\theta \mathbf e_z\mathbf e^T_z \\
&amp;= \begin{bmatrix}
1&amp; 0&amp; 0 \\
0&amp; 0&amp; 0 \\
0&amp; 0&amp; 0
\end{bmatrix} + \cos\theta \begin{bmatrix}
0&amp; 0&amp; 0 \\
0&amp; 1&amp; 0 \\
0&amp; 0&amp; 0
\end{bmatrix} + \sin \theta \begin{bmatrix}
0&amp; 0&amp; 0 \\
0&amp; 0&amp; 0 \\
0&amp; 1&amp; 0
\end{bmatrix} - \sin \theta \begin{bmatrix}
0&amp; 0&amp; 0 \\
0&amp; 0&amp; 1 \\
0&amp; 0&amp; 0
\end{bmatrix} + \cos\theta \begin{bmatrix}
0&amp; 0&amp; 0 \\
0&amp; 0&amp; 0 \\
0&amp; 0&amp; 1
\end{bmatrix} \\
&amp;= \begin{bmatrix}
1&amp; 0 &amp; 0 \\
0&amp; \cos \theta &amp; -\sin \theta \\
0&amp; \sin \theta &amp; \cos \theta
\end{bmatrix} \\
&amp;= R(x, \theta)
\end{aligned}
$$&lt;h3 id=&#34;arbitrary-rotation-vector&#34;&gt;arbitrary rotation vector&lt;/h3&gt;
&lt;p&gt;Now we set that specific derivation aside and consider an arbitrary rotation axis $\mathbf u\in\mathbb R^3$. Let $\mathbf v$ be a unit vector orthogonal to $\mathbf u$, and define $\mathbf w = \mathbf u \times \mathbf v$. The vectors $\mathbf u$, $\mathbf v$, and $\mathbf w$ then form an orthonormal basis.
In analogy with the simple case of rotation about the $x$-axis, rotating by $\theta$ about $\mathbf u$ gives
&lt;/p&gt;
$$
\begin{aligned} \mathbf u&#39; &amp;= \mathbf u \\ \mathbf v&#39; &amp;= \cos \theta \cdot \mathbf v + \sin \theta \cdot \mathbf w \\ \mathbf w&#39; &amp;= -\sin \theta \cdot \mathbf v + \cos \theta \cdot \mathbf w \end{aligned}
$$&lt;p&gt;
which can be expressed as matrix vector multiplication
&lt;/p&gt;
$$
\begin{bmatrix}\mathbf u&#39;&amp; \mathbf v&#39;&amp; \mathbf w&#39;\end{bmatrix} = \begin{bmatrix}\mathbf u&amp; \mathbf v&amp; \mathbf w\end{bmatrix}\begin{bmatrix}1&amp; 0 &amp; 0 \\
0&amp; \cos \theta &amp; -\sin \theta \\
0&amp; \sin \theta &amp; \cos \theta\end{bmatrix}
$$&lt;p&gt;
Then, based on these orthonormal vectors, there is a way to construct a rotation matrix&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; as
&lt;/p&gt;
$$
\begin{aligned}
R(\mathbf u, \theta) &amp;= \begin{bmatrix}\mathbf u&#39;&amp; \mathbf v&#39;&amp; \mathbf w&#39;\end{bmatrix} \begin{bmatrix}\mathbf u^T \\ \mathbf v^T \\ \mathbf w^T\end{bmatrix}\\
&amp;=\begin{bmatrix}\mathbf u&amp; \mathbf v&amp; \mathbf w\end{bmatrix}\begin{bmatrix}1&amp; 0 &amp; 0 \\
0&amp; \cos \theta &amp; -\sin \theta \\
0&amp; \sin \theta &amp; \cos \theta\end{bmatrix}\begin{bmatrix}\mathbf u^T \\ \mathbf v^T \\ \mathbf w^T\end{bmatrix} \\
&amp;= P S P^T
\end{aligned}
$$&lt;p&gt;
Generally, considering a vector $\mathbf l = a\mathbf u + b \mathbf v + c\mathbf w$ in a three dimensional space $\mathbb R^3$, the transformation of $\mathbf l$ is
&lt;/p&gt;
$$
\begin{aligned}
PSP^T \mathbf l &amp;= aPSP^T \mathbf u + b PSP^T\mathbf v + cPSP^T\mathbf w \\
&amp;= aPS\begin{bmatrix}\mathbf u^T \mathbf u \\ \mathbf v^T\mathbf u \\ \mathbf w^T \mathbf u\end{bmatrix} + bPS\begin{bmatrix}\mathbf u^T \mathbf v \\ \mathbf v^T\mathbf v \\ \mathbf w^T \mathbf v\end{bmatrix} + cPS\begin{bmatrix}\mathbf u^T \mathbf w \\ \mathbf v^T\mathbf w \\ \mathbf w^T \mathbf w\end{bmatrix} \\
&amp;= aPS\begin{bmatrix}\mathbf 1 \\ 0 \\ 0\end{bmatrix} + bPS\begin{bmatrix}\mathbf 0 \\ 1 \\ 0\end{bmatrix} + cPS\begin{bmatrix}\mathbf 0 \\ 0 \\ 1\end{bmatrix} \\
&amp;= aP \begin{bmatrix}\mathbf 1 \\ 0 \\ 0\end{bmatrix} + bP \begin{bmatrix}\mathbf 0 \\ \cos\theta \\ \sin \theta\end{bmatrix} + cP \begin{bmatrix}\mathbf 0 \\ -\sin\theta \\ \cos \theta\end{bmatrix} \\
&amp;= a\mathbf u + b (\cos\theta \mathbf v + \sin\theta \mathbf w) + c (-\sin\theta \mathbf v + \cos\theta \mathbf w) \\
&amp;= a\mathbf u&#39; + b\mathbf v&#39; + c\mathbf w&#39;
\end{aligned}
$$&lt;p&gt;
The above calculation shows that $PSP^T$ rotates the orthonormal basis by $\theta$ about $\mathbf u$. In other words, $PSP^T$ is the rotation matrix corresponding to the angle-axis pair $(\mathbf u, \theta)$.&lt;/p&gt;
&lt;h3 id=&#34;obtaining-rotation-matrix-only-based-u_1-u_2-u_3-and-theta&#34;&gt;obtaining rotation matrix only based $[u_1, u_2, u_3]$ and $\theta$&lt;/h3&gt;
&lt;p&gt;Although the $P$ matrix construction is valid, it is rather involved. A more convenient method is to express the angle-axis rotation as a sequence of Euler rotations. After a suitable change of basis that aligns $\mathbf u$, $\mathbf v$, and $\mathbf w$ with the $x$, $y$, and $z$ axes, the rotation by $\theta$ about $\mathbf u$ becomes a rotation by $\theta$ about the $x$-axis. The following procedure derives the rotation matrix for an arbitrary unit axis $\mathbf u$ and angle $\theta$&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;sup id=&#34;fnref:3&#34;&gt;&lt;a href=&#34;#fn:3&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;As the angle-axis representation only has the single rotation axis with $\theta$, the $x$-axis is chosen in this article.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;First rotate about the $z$-axis by $\gamma$ so that the axis $\mathbf u$ lies in the $x$-$z$ plane.&lt;/li&gt;
&lt;li&gt;Then rotate about the $y$-axis by $\beta$ so that $\mathbf u$ aligns with the $x$-axis.&lt;/li&gt;
&lt;li&gt;Perform the desired rotation by $\theta$ about the $x$-axis.&lt;/li&gt;
&lt;li&gt;Undo the second rotation by rotating about the $y$-axis by $-\beta$.&lt;/li&gt;
&lt;li&gt;Finally, undo the first rotation by rotating about the $z$-axis by $-\gamma$.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Thus, the rotation matrix can be expressed as
&lt;/p&gt;
$$
\begin{aligned}
R(\mathbf u, \theta) &amp;= R(z, -\gamma)R(y, -\beta)R(x, \theta)R(y,\beta)R(z, \gamma) \\
&amp;= \begin{bmatrix}\cos -\gamma&amp; -\sin-\gamma&amp; 0\\ \sin-\gamma&amp; \cos-\gamma&amp; 0\\ 0&amp; 0&amp; 1\end{bmatrix}
\begin{bmatrix}\cos -\beta&amp; 0&amp; \sin-\beta\\ 0&amp; 1&amp; 0 \\ -\sin-\beta&amp; 0&amp; \cos- \beta\end{bmatrix}
\begin{bmatrix}1&amp; 0 &amp; 0 \\
0&amp; \cos \theta &amp; -\sin \theta \\
0&amp; \sin \theta &amp; \cos \theta\end{bmatrix}
\begin{bmatrix}\cos \beta&amp; 0&amp; \sin\beta\\ 0&amp; 1&amp; 0 \\ -\sin\beta&amp; 0&amp; \cos\beta\end{bmatrix}
\begin{bmatrix}\cos \gamma&amp; -\sin\gamma&amp; 0\\ \sin\gamma&amp; \cos\gamma&amp; 0\\ 0&amp; 0&amp; 1\end{bmatrix}
\end{aligned}
$$&lt;p&gt;
Here $\cos \gamma$, $\sin \gamma$, $\cos \beta$, and $\sin \beta$ are determined from the underlying three-dimensional geometry. The order of multiplication is essential because it reflects the order of coordinate transformations.&lt;/p&gt;











&lt;figure class=&#34;site-figure center&#34;&gt;
  
    
    
      
      
      
      
      
        
        
      
        
        
      
      
      
      
      
      
      &lt;img src=&#34;https://herding.github.io/posts/angle_axis/rotation_hu_d9acec119906d981.png&#34; srcset=&#34;https://herding.github.io/posts/angle_axis/rotation_hu_d10f9d80e2b60a5.png 600w, https://herding.github.io/posts/angle_axis/rotation_hu_d9acec119906d981.png 1200w&#34; sizes=&#34;(max-width: 600px) 100vw, 600px&#34; alt=&#34;allocation&#34; ZgotmplZ&gt;
    
  
    &lt;figcaption&gt;Illustration: from CS 4733 Class Notes: Composite Rotations&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;To compute these trigonometric values, consider rotating $\mathbf u = [u_1, u_2, u_3]^T$ about the $z$-axis until it lies in the $x$-$z$ plane. The transformed axis is $[u&amp;rsquo;_1, u&amp;rsquo;_2, u&amp;rsquo;_3]^T$ with $u&amp;rsquo;_2 = 0$, and it satisfies
&lt;/p&gt;
$$
\begin{aligned}
\begin{bmatrix}
u&#39;_1 \\
u&#39;_2 \\
u&#39;_3
\end{bmatrix} &amp;= \begin{bmatrix}\cos \gamma&amp; -\sin\gamma&amp; 0\\ \sin\gamma&amp; \cos\gamma&amp; 0\\ 0&amp; 0&amp; 1\end{bmatrix} \begin{bmatrix}
u_1 \\
u_2 \\
u_3
\end{bmatrix} \\
&amp;= \begin{bmatrix}
u_1\cos\gamma  - u_2\sin\gamma \\
u_1\sin \gamma + u_2 \cos \gamma \\
u_3
\end{bmatrix}
\end{aligned}
$$&lt;p&gt;
Since $u&amp;rsquo;_2 = u_1\sin\gamma + u_2\cos\gamma = 0$, it is rearranged as
&lt;/p&gt;
$$
\begin{aligned} u_1\sin\gamma &amp;= -u_2\cos\gamma \\ \frac{\sin\gamma}{\cos\gamma} &amp;= -\frac{u_2}{u_1} \end{aligned}
$$&lt;p&gt;
Thus, according to the geometric relation as shown in the figure and the above equation, $\cos \gamma$ and $\sin \gamma$ are equal to
&lt;/p&gt;
$$
\begin{aligned}
\cos \gamma &amp;= \frac{u_1}{\sqrt{u_1^2 + u_2^2}} \\
\sin \gamma &amp;= -\frac{u_2}{\sqrt{u_1^2 + u_2^2}}
\end{aligned}
$$&lt;p&gt;
Similarly, rotating about the $y$-axis by $\beta$ aligns the axis with the $x$-axis. Using $||\mathbf u|| = 1$, we obtain
&lt;/p&gt;
$$
\begin{aligned}
\cos \beta &amp;= \frac{\sqrt{u_1^2 + u_2^2}}{\sqrt{u_1^2+u_2^2+u_3^2}} = \sqrt{u_1^2 + u_2^2},\\
\sin \beta &amp;= \frac{u_3}{\sqrt{u_1^2+u_2^2+u_3^2}} = u_3.
\end{aligned}
$$&lt;blockquote&gt;
&lt;p&gt;HINT:
&lt;/p&gt;
$$u&#39;&#39;_3 = -u&#39;_1 \sin\beta +u&#39;_3\cos\beta  = 0$$&lt;p&gt;
Then, $\sin\beta / \cos\beta = u&amp;rsquo;_3 / u&amp;rsquo;_1$.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;In addition, considering $||\mathbf u|| = 1$, we also have $1 = u_1^2 + u_2^2 + u_3^2$. Then, the rotation matrix can be rewritten as
&lt;/p&gt;
$$
\begin{aligned}
R(\mathbf u, \theta) &amp;= \begin{bmatrix}u^2_1 (1 - \cos\theta) + \cos\theta&amp; u_1u_2(1 - \cos\theta) - u_3\sin \theta&amp; u_1u_3(1 - \cos\theta) + u_2\sin \theta\\
u_1u_2(1 - \cos \theta) + u_3\sin \theta&amp; u^2_2(1 - \cos\theta) + \cos\theta&amp;  u_2u_3(1 - \cos \theta) -u_1\sin\theta \\
u_1u_3(1 - \cos\theta) - u_2\sin \theta&amp; u_2u_3(1 - \cos \theta) + u_1\sin \theta &amp; u^2_3(1 - \cos\theta) + \cos\theta
\end{bmatrix}
\end{aligned}
$$&lt;blockquote&gt;
&lt;p&gt;HINT:
&lt;/p&gt;
$$\begin{aligned}R(\mathbf u, \theta) &amp;= R(z, -\gamma)R(y, -\beta)R(x, \theta)R(y,\beta)R(z, \gamma) \\&amp;= \begin{bmatrix}\cos -\gamma&amp; -\sin-\gamma&amp; 0\\ \sin-\gamma&amp; \cos-\gamma&amp; 0\\ 0&amp; 0&amp; 1\end{bmatrix}\begin{bmatrix}\cos -\beta&amp; 0&amp; \sin-\beta\\ 0&amp; 1&amp; 0 \\ -\sin-\beta&amp; 0&amp; \cos- \beta\end{bmatrix}\begin{bmatrix}1&amp; 0 &amp; 0 \\0&amp; \cos \theta &amp; -\sin \theta \\0&amp; \sin \theta &amp; \cos \theta\end{bmatrix}\begin{bmatrix}\cos \beta&amp; 0&amp; \sin\beta\\ 0&amp; 1&amp; 0 \\ -\sin\beta&amp; 0&amp; \cos\beta\end{bmatrix}\begin{bmatrix}\cos \gamma&amp; -\sin\gamma&amp; 0\\ \sin\gamma&amp; \cos\gamma&amp; 0\\ 0&amp; 0&amp; 1\end{bmatrix} \\&amp;= \begin{bmatrix}\cos \gamma&amp; \sin\gamma&amp; 0\\ -\sin\gamma&amp; \cos\gamma&amp; 0\\ 0&amp; 0&amp; 1\end{bmatrix}\begin{bmatrix}\cos \beta&amp; 0&amp; -\sin\beta\\ 0&amp; 1&amp; 0 \\ \sin\beta&amp; 0&amp; \cos\beta\end{bmatrix}\begin{bmatrix}1&amp; 0 &amp; 0 \\0&amp; \cos \theta &amp; -\sin \theta \\0&amp; \sin \theta &amp; \cos \theta\end{bmatrix}\begin{bmatrix}\cos \beta&amp; 0&amp; \sin\beta\\ 0&amp; 1&amp; 0 \\ -\sin\beta&amp; 0&amp; \cos\beta\end{bmatrix}\begin{bmatrix}\cos \gamma&amp; -\sin\gamma&amp; 0\\ \sin\gamma&amp; \cos\gamma&amp; 0\\ 0&amp; 0&amp; 1\end{bmatrix} \\&amp;= \begin{bmatrix}\frac{u_1}{s}&amp; -\frac{u_2}{s}&amp; 0 \\\frac{u_2}{s}&amp; \frac{u_1}{s}&amp; 0 \\0&amp; 0&amp; 1\end{bmatrix} \begin{bmatrix}s&amp; 0&amp; -u_3 \\0&amp; 1&amp; 0 \\u_3&amp; 0&amp; s \\\end{bmatrix} \begin{bmatrix}1&amp; 0 &amp; 0 \\0&amp; \cos \theta &amp; -\sin \theta \\0&amp; \sin \theta &amp; \cos \theta\end{bmatrix}  \begin{bmatrix}s&amp; 0&amp; u_3 \\0&amp; 1&amp; 0 \\-u_3&amp; 0&amp; s \\\end{bmatrix} \begin{bmatrix}\frac{u_1}{s}&amp; \frac{u_2}{s}&amp; 0 \\-\frac{u_2}{s}&amp; \frac{u_1}{s}&amp; 0 \\0&amp; 0&amp; 1\end{bmatrix} \\&amp;= \begin{bmatrix}u_1&amp; -\frac{u_2}{s}&amp; -\frac{u_1u_3}{s}  \\u_2&amp; \frac{u_1}{s}&amp; -\frac{u_2u_3}{s} \\u_3&amp; 0&amp; s\end{bmatrix} \begin{bmatrix}1&amp; 0 &amp; 0 \\0&amp; \cos \theta &amp; -\sin \theta \\0&amp; \sin \theta &amp; \cos \theta\end{bmatrix}  \begin{bmatrix}u_1&amp; u_2&amp; u_3 \\-\frac{u_2}{s}&amp; \frac{u_1}{s}&amp; 0 \\-\frac{u_1u_3}{s}&amp; -\frac{u_2u_3}{s}&amp; s\end{bmatrix}  \\&amp;= \begin{bmatrix}u_1&amp; -\frac{u_2}{s}\cos\theta - \frac{u_1u_3}{s}\sin\theta&amp; \frac{u_2}{s}\sin\theta - \frac{u_2u_3}{s}\cos\theta \\u_2&amp; \frac{u_1}{s}\cos\theta - \frac{u_2u_3}{s}\sin\theta&amp; -\frac{u_1}{s}\sin\theta - \frac{u_2u_3}{s}\cos\theta \\u_3&amp; s\sin\theta&amp; s\cos\theta\end{bmatrix} \begin{bmatrix}u_1&amp; u_2&amp; u_3 \\-\frac{u_2}{s}&amp; \frac{u_1}{s}&amp; 0 \\-\frac{u_1u_3}{s}&amp; -\frac{u_2u_3}{s}&amp; s\end{bmatrix}\\&amp;= \begin{bmatrix}u^2_1 + \frac{u^2_2}{s^2}\cos\theta + \frac{u_1u_2u_3}{s^2}\sin\theta - \frac{u_1u_2u_3}{s^2}\sin\theta + \frac{u^2_1u^2_3}{s^2}\cos\theta&amp; u_1u_2-\frac{u_1u_2}{s^2}\cos\theta - \frac{u^2_1u_3}{s^2}\sin\theta - \frac{u^2_2u_3}{s^2}\sin\theta + \frac{u_1u_2u_3^2}{s^2}\cos\theta &amp; u_1u_3+u_2\sin\theta-u_1u_3\cos\theta \\u_1u_2-\frac{u_1u_2}{s^2}\cos\theta + \frac{u^2_2u_3}{s^2}\sin\theta + \frac{u^2_1u_3}{s^2}\sin\theta + \frac{u_1u_2u^2_3}{s^2}\cos\theta&amp; u^2_2 + \frac{u^2_1}{s^2}\cos\theta - \frac{u_1u_2u_3}{s^2}\sin\theta + \frac{u_1u_2u_3}{s^2}\sin\theta + \frac{u^2_2u^2_3}{s^2}\cos\theta &amp; u_2u_3 -u_1\sin\theta -u_2u_3\cos\theta \\u_1u_3 - u_2 \sin\theta - u_1u_3\cos\theta&amp; u_2u_3+u_1\sin\theta -u_2u_3\cos\theta&amp; u^2_3+s^2 \cos\theta \end{bmatrix} \\&amp;= \begin{bmatrix}u^2_1 + \frac{u^2_2+u^2_1u^2_3}{s^2}\cos\theta&amp; u_1u_2(1 - \cos\theta) - u_3\sin\theta&amp; u_1u_3 (1 - \cos\theta)+u_2\sin\theta \\u_1u_2(1 - \cos\theta) + u_3\sin\theta&amp; u_2^2+ \frac{u^2_1+u^2_2u^2_3}{s^2}\cos\theta&amp; u_2u_3(1 - \cos\theta)-u_1\sin\theta \\u_1u_3(1 - \cos\theta) -u_2\sin\theta&amp; u_2u_3(1 - \cos\theta) + u_1\sin\theta &amp; u^2_3 + (1 - u^2_3)\cos\theta\end{bmatrix}\end{aligned}$$&lt;p&gt;
where $s = \sqrt{u_1^2 + u_2^2}$. In addition,
&lt;/p&gt;
$$\begin{aligned}(1 - u_1^2)(u^2_1 + u^2_2) &amp;= (u^2_2 + u^2_3)(u^2_1+u^2_2) \\&amp;= u^2_2u^2_1 + u^4_2+ u^2_1u^2_3 + u^2_2u^2_3 \\&amp;= u^4_2 + u^2_2(u^2_1+u^2_3) + u^2_1u^2_3 \\&amp;= u^4_2 + u^2_2(1 - u^2_2) + u^2_2u^2_3 \\&amp;= u^2_2 + u^2_1u^2_3\end{aligned}$$&lt;p&gt;
and $u^2_1 + u^2_2u^2_3 = (1-u^2_2)(u^2_1 + u^2_2)$, so the result is calculated and simplifed by using these condition.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Now that the rotation matrix has been derived from the angle-axis, it is worth noting a simpler and more direct formula. &lt;a href=&#34;https://en.wikipedia.org/wiki/Rodrigues&#39;_rotation_formula&#34;&gt;Rodrigues&amp;rsquo; rotation formula&lt;/a&gt; (also known as the &lt;a href=&#34;https://en.wikipedia.org/wiki/Euler%E2%80%93Rodrigues_formula#Vector_formulation&#34;&gt;Euler–Rodrigues formula&lt;/a&gt;) computes the matrix $R(\mathbf u, \theta)$ directly. Thus, the rotation matrix is often written as
&lt;/p&gt;
$$
R(\mathbf u, \theta) = I +\sin\theta [\mathbf u]_\times + (1 - \cos\theta)[\mathbf u]_\times^2
$$&lt;p&gt;
where $[\mathbf u]_\times$ is a skew symmetric matrix introduced in &lt;a href=&#34;https://herding.github.io/posts/angular_velocity&#34;&gt;Angular Velocity&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;from-rotation-matrix-to-angle-axis&#34;&gt;From rotation matrix to angle-axis&lt;/h2&gt;
&lt;p&gt;This section focuses on recovering the angle-axis representation from a given rotation matrix. We first extract the axis direction $\mathbf u$, then derive the rotation angle $\theta$ from the matrix.&lt;/p&gt;
&lt;h3 id=&#34;infer-mathbf-u&#34;&gt;infer $\mathbf u$&lt;/h3&gt;
&lt;p&gt;Because $\mathbf u$ lies on the rotation axis, it remains unchanged by the rotation, which means
&lt;/p&gt;
$$
R\mathbf u = \mathbf u
$$&lt;p&gt;
It is also unchanged by the inverse rotation, that is,
&lt;/p&gt;
$$
R^{-1}\mathbf u = \mathbf u
$$&lt;p&gt;
while $R^{-1} = R^T$ because of the property of rotation matrix $R$. Thus, $R\mathbf u = R^{-1}\mathbf u = R^T\mathbf u = \mathbf u$. Then, we have
&lt;/p&gt;
$$
\begin{aligned}
R\mathbf u - R^T\mathbf u &amp;= (R - R^T)\mathbf u \\
&amp;= \begin{bmatrix}0&amp; r_{12} - r_{21}&amp; r_{13} - r_{31} \\
r_{21} - r_{12}&amp; 0&amp; r_{23}-r_{32} \\
r_{31} - r_{13}&amp; r_{32} - r_{23}&amp; 0 \\
\end{bmatrix}  \mathbf u\\
&amp;= 0
\end{aligned}
$$&lt;p&gt;
Recalling the definition of skew symmetric matrix for a vector $\mathbf a = [a_1, a_2, a_3]^T$, it is expressed as
&lt;/p&gt;
$$
[\mathbf a]_\times = \begin{bmatrix} 0&amp; -a_3&amp; a_2 \\ a_3&amp; 0&amp; -a_1 \\ -a_2&amp; a_1&amp; 0 \end{bmatrix}
$$&lt;p&gt;
Then $R - R^T$ can be viewed as the skew-symmetric matrix of a vector $\mathbf a$, and the components of $\mathbf a$ are
&lt;/p&gt;
$$
\begin{aligned}
a_1 &amp;= r_{32} - r_{23} \\
a_2 &amp;= r_{13} - r_{31} \\
a_3 &amp;= r_{21} - r_{12}
\end{aligned}
$$&lt;p&gt;
Rearranging the equation of $(R - R^T)\mathbf u$ by using $[\mathbf a]_\times$, it is expressed as
&lt;/p&gt;
$$
\begin{aligned}
(R - R^T)\mathbf u &amp;= [\mathbf a]_\times \mathbf u \\
&amp;= \mathbf a \times \mathbf u \\
&amp;= 0
\end{aligned}
$$&lt;p&gt;
Thus, $\mathbf a$ is parallel with $\mathbf u$, because $\mathbf a \times \mathbf u = 0$. Then, the direction vector of $\mathbf u$ in the angle-axis representation is inferred as
&lt;/p&gt;
$$
\mathbf u = \frac{\mathbf a}{\|\mathbf a\|}
$$&lt;p&gt;
One may ask why $\mathbf a$ is not directly equal to $\mathbf u$. To answer this, recall the $P$ matrix representation of the rotation matrix, and express $R - R^T$ as
&lt;/p&gt;
$$
\begin{aligned}
R - R^T &amp;=  PSP^T - PS^TP^T\\
&amp;= P(S - S^T)P^T \\
&amp;= P\begin{bmatrix}0&amp; 0 &amp; 0 \\
0&amp; 0 &amp; -2\sin \theta \\
0&amp; 2\sin \theta &amp; 0\end{bmatrix}P^T \\
&amp;= \begin{bmatrix}
0&amp; 2\sin\theta \mathbf w&amp; -2\sin\theta \mathbf v \\
\end{bmatrix} P^T \\
&amp;= (2\sin\theta \mathbf w\mathbf v^T - 2\sin\theta\mathbf v\mathbf w^T)  \\
&amp;= 2\sin \theta (\mathbf w\mathbf v^T - \mathbf v\mathbf w^T)
\end{aligned}
$$&lt;p&gt;
when $\mathbf v = [v_1, v_2, v_3]^T$ and $\mathbf w = [w_1, w_2, w_3]^T$, the above equation is rewritten as
&lt;/p&gt;
$$
\begin{aligned}
R - R^T &amp;= 2\sin\theta \begin{bmatrix}
w_1v_1&amp; w_1v_2&amp; w_1v_3 \\
w_2v_1&amp; w_2v_2&amp; w_2v_3 \\
w_3v_1&amp; w_3v_2&amp; w_3v_3 \\
\end{bmatrix} - 2\sin \theta \begin{bmatrix}
v_1w_1&amp; v_1w_2&amp; v_1w_3 \\
v_2w_1&amp; v_2w_2&amp; v_2w_3 \\
v_3w_1&amp; v_3w_2&amp; v_3w_3 \\
\end{bmatrix} \\
&amp;= 2\sin \theta \begin{bmatrix}
0&amp; w_1v_2 - v_1w_2&amp; w_1v_3 - v_1w_3 \\
w_2v_1 - v_2w_1&amp; 0&amp; w_2v_3 - v_2w_3 \\
w_3v_1 - v_3w_1&amp; w_3v_2 - v_3w_2 &amp;0
\end{bmatrix} \\
&amp;= \begin{bmatrix}0&amp; -a_3&amp; a_2\\
a_3&amp; 0&amp; -a_1 \\
-a_2&amp; a_1&amp; 0 \\
\end{bmatrix} 
\end{aligned}
$$&lt;p&gt;
Thus, we have
&lt;/p&gt;
$$
\begin{aligned} a_1 &amp;= 2\sin\theta (v_2w_3 - v_3w_2) \\ a_2 &amp;= 2\sin\theta(v_3w_1 - v_1w_3) \\ a_3 &amp;= 2\sin\theta(v_1w_2 - v_2w_1) \\ \end{aligned}
$$&lt;p&gt;
which can be expressed as cross product between $\mathbf v$ and $\mathbf w$&lt;sup id=&#34;fnref1:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;, that is
&lt;/p&gt;
$$
\mathbf a = 2\sin\theta \mathbf v \times \mathbf w = 2\sin \theta \mathbf u
$$&lt;p&gt;
Thus $\mathbf a$ is parallel to $\mathbf u$ and its magnitude is $2||\sin\theta||$.&lt;/p&gt;
&lt;h3 id=&#34;infer-theta&#34;&gt;infer $\theta$&lt;/h3&gt;
&lt;p&gt;Now we infer the rotation angle $\theta$ in the angle-axis representation. Using $R(\mathbf u, \theta) = PSP^T$ and the fact that similar matrices have the same trace, we obtain
&lt;/p&gt;
$$
\begin{aligned}
tr(R) = tr(PSP^T) = tr(PSP^{-1}) = tr(P^{-1}PS) = tr(S) = 1 + 2\cos\theta
\end{aligned}
$$&lt;p&gt;
Therefore,
&lt;/p&gt;
$$
\theta = \arccos\left(\frac{\operatorname{tr}(R) - 1}{2}\right).
$$&lt;p&gt;
Combined with $\mathbf a = 2\sin\theta,\mathbf u$, this recovers both the rotation axis and the signed angle.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;HINT: $P^T = P^{-1}$
&lt;/p&gt;
$$\begin{aligned}P^T P &amp;= \begin{bmatrix}\mathbf u^T \\ \mathbf v^T \\ \mathbf w^T\end{bmatrix}\begin{bmatrix}\mathbf u&amp;\mathbf v&amp;\mathbf w\end{bmatrix} \\&amp;= \begin{bmatrix}\mathbf u^T\mathbf u &amp; \mathbf u^T\mathbf v&amp; \mathbf u^T\mathbf w \\ \mathbf v^T \mathbf u &amp; \mathbf v^T\mathbf v&amp; \mathbf v^T\mathbf w \\ \mathbf w^T\mathbf u &amp; \mathbf w^T\mathbf v&amp; \mathbf w^T\mathbf w\end{bmatrix} \\&amp;= \begin{bmatrix}1&amp; 0&amp; 0\\ 0&amp;1&amp; 0\\ 0&amp; 0 &amp; 1\end{bmatrix} = P^{-1}P\end{aligned}$$&lt;/blockquote&gt;
&lt;h3 id=&#34;special-cases&#34;&gt;special cases&lt;/h3&gt;
&lt;p&gt;Finally, note the special cases when $R = R^T$. In those cases the rotation angle is either $0$ or $\pi$. As discussed in lecture notes&lt;sup id=&#34;fnref2:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;, if $\theta = 0$, then
&lt;/p&gt;
$$
\begin{aligned}
R(\mathbf u, \theta) &amp;= PSP^T \\
&amp;= \begin{bmatrix}\mathbf u&amp; \mathbf v&amp; \mathbf w\end{bmatrix}\begin{bmatrix}1&amp; 0 &amp; 0 \\
0&amp; \cos \theta &amp; -\sin \theta \\
0&amp; \sin \theta &amp; \cos \theta\end{bmatrix}\begin{bmatrix}\mathbf u^T \\ \mathbf v^T \\ \mathbf w^T\end{bmatrix} \\
&amp;= \begin{bmatrix}\mathbf u&amp; \mathbf v&amp; \mathbf w\end{bmatrix}\begin{bmatrix}1&amp; 0 &amp; 0 \\
0&amp; 1 &amp; 0 \\
0&amp; 0 &amp; 1\end{bmatrix}\begin{bmatrix}\mathbf u^T \\ \mathbf v^T \\ \mathbf w^T\end{bmatrix} \\
&amp;= I
\end{aligned}
$$&lt;p&gt;
Also, the axis direction remains $\mathbf u$. If $\theta = \pi$, the rotation matrix is expressed as
&lt;/p&gt;
$$
\begin{aligned}
R(\mathbf u, \theta) &amp;= PSP^T \\
&amp;= \begin{bmatrix}\mathbf u&amp; \mathbf v&amp; \mathbf w\end{bmatrix}\begin{bmatrix}1&amp; 0 &amp; 0 \\
0&amp; \cos \theta &amp; -\sin \theta \\
0&amp; \sin \theta &amp; \cos \theta\end{bmatrix}\begin{bmatrix}\mathbf u^T \\ \mathbf v^T \\ \mathbf w^T\end{bmatrix} \\
&amp;= \begin{bmatrix}\mathbf u&amp; \mathbf v&amp; \mathbf w\end{bmatrix}\begin{bmatrix}1&amp; 0 &amp; 0 \\
0&amp; -1 &amp; 0 \\
0&amp; 0 &amp; -1\end{bmatrix}\begin{bmatrix}\mathbf u^T \\ \mathbf v^T \\ \mathbf w^T\end{bmatrix} \\
&amp;= \begin{bmatrix} \mathbf u &amp;-\mathbf v &amp;-\mathbf w\end{bmatrix}\begin{bmatrix}\mathbf u^T \\ \mathbf v^T \\ \mathbf w^T\end{bmatrix} \\
&amp;= \mathbf u\mathbf u^T - \mathbf v\mathbf v^T - \mathbf w\mathbf w^T
\end{aligned}
$$&lt;p&gt;
Since $\mathbf u, \mathbf v$ and $\mathbf w$ are orthonormal basis, $\mathbf u\mathbf u^T + \mathbf v\mathbf v^T + \mathbf w\mathbf w^T = I$, then the rotation matrix is rewritten as
&lt;/p&gt;
$$
R(\mathbf u, \theta) = 2\mathbf u\mathbf u^T - I
$$&lt;p&gt;
So the direction vector can be derived from $R(\mathbf u, \theta) + I$ where the nonzero column is parallel to $\mathbf u$.&lt;/p&gt;
&lt;p&gt;In conclusion, the angle-axis representation is another mathematical way to describe rotation. It can be converted into a rotation matrix or a set of Euler angles. Although the angle-axis form has special cases such as $\theta = 0$ or $\theta = \pi$, it does not suffer from gimbal lock by itself; gimbal lock may only appear after converting to Euler angles.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;Lectures notes on rotations 92.222, Linear Algebra II Spring 2005. D. Klain.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref1:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref2:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;CS 4733 Class Notes: Composite Rotations&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:3&#34;&gt;
&lt;p&gt;Cole, Ian R. (January 2015). Section 9.2 in &lt;a href=&#34;https://dspace.lboro.ac.uk/dspace-jspui/handle/2134/18050&#34;&gt;&lt;em&gt;Modelling CPV&lt;/em&gt;&lt;/a&gt;(thesis). Loughborough University.&amp;#160;&lt;a href=&#34;#fnref:3&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Euler Angles</title>
      <link>https://herding.github.io/posts/euler_angle/</link>
      <pubDate>Sun, 19 Apr 2026 20:46:22 +0800</pubDate>
      
      <guid>https://herding.github.io/posts/euler_angle/</guid>
      <description>&lt;p&gt;Rotation is used for describing the pose in a base frame and is expressed as a rotation matrix that has been introduced in previous articles. Actually, there are several ways to numerically express the rotation, except for the rotation matrix, including Euler angles, axis-angle, and unit quaternions. Of course, one representation can be directly or indirectly transformed into another representation. Next, this article will introduce Euler angles and their relationship to the rotation matrix.&lt;/p&gt;
&lt;h2 id=&#34;rotation-matrix&#34;&gt;Rotation matrix&lt;/h2&gt;
&lt;p&gt;Rotation matrix was introduced previously, which is constructed by parameters derived from &lt;a href=&#34;https://herding.github.io/posts/dh_convention/&#34;&gt;Denavit Hartenberg Convention&lt;/a&gt;. Consequently, a rotation can be expressed as a sequence of three elementary rotations, $Rot(x, \alpha), Rot(y, \beta)$ and $Rot(z, \gamma)$. Thus, intuitively, the minimal representation of rotations is only three independent parameters, rather than 9 parameters in the rotation matrix. According to the property of rotation, $RR^T=I$, three independent parameters is enough to represent a rotation, such as Euler angles&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;h2 id=&#34;euler-angles&#34;&gt;Euler angles&lt;/h2&gt;
&lt;p&gt;There are many ways to represent rotations resulting in a rotation matrix, such as ZYX Euler angles (intrinsic rotation), XYZ Euler angles (extrinsic rotation), and so on&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;. ZYX Euler angles are also known as Tait-Bryan angles (or yaw-pitch-roll) and are used for flying vehicles, while XYZ Euler angles are often used for robotics, also called Cardan angles. They have a similar construction, so XYZ Euler angles are taken as an example here and are collected as
&lt;/p&gt;
$$
[\alpha, \beta, \gamma]^T
$$&lt;p&gt;
where $\alpha, \beta$ and $\gamma$ rotate around $x, y$ and $z$ axes, respectively.&lt;/p&gt;
&lt;h3 id=&#34;euler-angles-to-rotation-matrix&#34;&gt;Euler angles to rotation matrix&lt;/h3&gt;
&lt;p&gt;From the Euler angles, the rotation can be naturally expressed as
&lt;/p&gt;
$$
\begin{aligned}
R &amp;= Rot(x, \alpha)Rot(y, \beta)Rot(z, \gamma) \\
&amp;= \begin{bmatrix}\cos\beta\cos\gamma&amp; -\cos\beta\sin\gamma&amp; \sin\beta \\
\cos\alpha\sin\gamma + \cos\gamma\sin\alpha\sin\beta&amp; \cos\alpha\cos\gamma-\sin\alpha\sin\beta\sin\gamma&amp; -\cos\beta\sin\alpha \\
\sin\alpha\sin\gamma - \cos\alpha\cos\gamma\sin\beta&amp; \cos\gamma\sin\alpha+\cos\alpha\sin\beta\sin\gamma&amp; \cos\alpha\cos\beta
\end{bmatrix}
\end{aligned}
$$&lt;h3 id=&#34;rotation-matrix-to-euler-angles&#34;&gt;Rotation matrix to Euler angles&lt;/h3&gt;
&lt;p&gt;Thus, assuming $\beta \in (-\pi/2, \pi / 2)$ and $\cos\alpha \neq 0$, then $\tan\alpha = -R_{23} / R_{33}$ according to the definition of $\tan\alpha = \sin\alpha / \cos\alpha$, where $R_{ij}$ is the element at $i$th row and $j$th column of rotation matrix $R$.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Hint:
&lt;/p&gt;
$$\frac{-R_{23}}{R_{33}} = \frac{-(-\cos\beta\sin\alpha)}{\cos\alpha\cos\beta} = \frac{\sin\alpha}{\cos\alpha} = \tan\alpha$$&lt;p&gt; when $\cos \alpha \neq 0$ and $\cos \beta \in (0, 1]$ because of $\beta \in (-\pi / 2, \pi/2)$.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;In order to accurately infer the angle $\alpha$, the function $atan2(\sin \alpha, \cos\alpha)$ is a good choice, which returns the angle between $-\pi$ and $\pi$ based on $\sin\alpha$, $\cos \alpha$ and their signs ($+$ or $-$). So, $\alpha$ is derived as $atan2(-R_{23}, R_{33})$.
Similarly, $\tan\beta = R_{13} / \sqrt{R^2_{11} + R^2_{12}}$ and $\tan \gamma = -R_{12} / R_{11}$ ($R_{11} \neq 0$). In the end, the inverse solution from a rotation matrix to Euler angles is
&lt;/p&gt;
$$
\begin{bmatrix}
\alpha \\
\beta \\
\gamma \\
\end{bmatrix} = \begin{bmatrix}
atan2(-R_{23}, R_{33}) \\
atan2(R_{13}, \sqrt{R^2_{11} + R^2_{12}}) \\
atan2(-R_{12}, R_{11})
\end{bmatrix}.
$$&lt;p&gt;We have to notice that the above result is derived from an assumption that $\cos \beta &amp;gt; 0$. The above transformation from rotation matrix to Euler angles cannot deal with $\beta$ belonging to $[-\pi, -\pi/2]$ or $[\pi/2, \pi]$. Especially, $\beta = \pm \pi /2$ causes the other axes to overlap, which is called Gimbal lock.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;2.4.5 Representation of Rotations. Robot Dynamics Lecture Notes.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Euler_angles&#34;&gt;Euler angles&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Inverse Kinematics</title>
      <link>https://herding.github.io/posts/ik/</link>
      <pubDate>Sun, 22 Mar 2026 19:35:32 +0800</pubDate>
      
      <guid>https://herding.github.io/posts/ik/</guid>
      <description>&lt;p&gt;Forward kinematics is a problem that, given a set of joint configurations of a robot, infers the position and orientation of the end-effector. On the contrary, given the desired position and orientation of the end-effector to infer an acceptable joint configuration is another problem called the Inverse Kinematics (IK) problem. In this essay, a simple approach will be introduced based on the position and orientation error between the target pose and the initial pose.&lt;/p&gt;
&lt;p&gt;There are many approaches proposed for solving the IK problem over the decades, which can be split into two classical categories: analytical IK and numerical IK.&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt; Although analytical IK provides a closed-form expression that is really fast to compute without the initial joint configuration $\mathbf q_0$, it depends on the specific robot that has distinct kinematic structures and is often tedious or difficult to derive using sine and cosine, especially for robots with a high degree of freedom.&lt;/p&gt;
&lt;h2 id=&#34;error-function-in-ik&#34;&gt;error function in IK&lt;/h2&gt;
&lt;p&gt;Thus, numerical IK approaches are widely studied and used, which also have many particular methods. The main part of numerical IK is Differential Inverse Kinematics (DIK), sometimes called Closed-Loop Inverse Kinematics (CLIK). At first, DIK was proposed for solving the following equation,
&lt;/p&gt;
$$
\mathbf e(\mathbf q) = \mathbf 0
$$&lt;p&gt;
where $\mathbf e(\cdot)$ is an error function that is defined as
&lt;/p&gt;
$$
\mathbf e(\mathbf q) = \begin{cases}^d\mathbf p - \mathbf p(\mathbf q),&amp;\text{for position}, \\
a(^dRR^T(\mathbf q)),&amp; \text{for orientation}.
\end{cases}
$$&lt;p&gt;
The desired position and the position are represented as $^d\mathbf p$ and $\mathbf p(\mathbf q)$, respectively. In addition, $R(\mathbf q)$ and $^dR$ are the orientation and its desired value of the link of interest. The result of $^dRR^T(\mathbf q)$ means transforming the pose rotated by $R$ into the desired pose.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;HINT:&lt;/p&gt;
&lt;p&gt;The current pose is $\mathbf o = R \mathbf p_{base}$ after rotation in the base frame, while the target pose is $^dR \mathbf p_{base}$. Thus, the target pose can be expressed as $^dR R^{-1} \mathbf o = ^dR R^T \mathbf o$ where $^dR R^T$ is also a rotation matrix transforming from $\mathbf o$ to the target pose.&lt;/p&gt;&lt;/blockquote&gt;
&lt;h2 id=&#34;relative-error-of-rotation&#34;&gt;relative error of rotation&lt;/h2&gt;
&lt;p&gt;In order to calculate the error $\mathbf e(\mathbf q)$, the position error can be directly calculated, while calculating the orientation error $^dR R^T(\mathbf q)$ depends on the $a(\cdot)$ that maps the rotation matrix to a rotation vector. As shown in &lt;a href=&#34;https://herding.github.io/posts/angular_velocity&#34;&gt;angular velocity&lt;/a&gt;, rotation vector $\phi$ is presented as a product of  an axis $\mathbf u$ and its magnitude $\theta$ (radians per unit time).&lt;/p&gt;
&lt;p&gt;The rotation axis is expressed as a vector $\mathbf u$ that is expressed using these elements of the rotation matrix
&lt;/p&gt;
$$
\begin{aligned}\Delta R =\ ^dRR^T(\mathbf q) &amp;= \begin{bmatrix}r_{11}&amp; r_{12}&amp; r_{13} \\ r_{21}&amp; r_{22}&amp; r_{23} \\ r_{31}&amp; r_{32}&amp; r_{33}\end{bmatrix} \\ \mathbf u &amp;= \begin{bmatrix}r_{32} - r_{23} \\ r_{13} - r_{31} \\ r_{21} - r_{12}\end{bmatrix}\end{aligned}$$&lt;blockquote&gt;
&lt;p&gt;HINT&lt;sup id=&#34;fnref:3&#34;&gt;&lt;a href=&#34;#fn:3&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;
&lt;p&gt;Since the vector $\mathbf u$ after rotation is itself, there is $\Delta R \mathbf u = \mathbf u = I\mathbf u$ that implies $(\Delta R - I)\mathbf u = 0$. Then, we have
&lt;/p&gt;
$$\begin{aligned}\Delta R^T(\Delta R - I)\mathbf u + (\Delta R - I)\mathbf u &amp;= (\Delta R^T \Delta R - \Delta R^T)\mathbf u + (\Delta R - I)\mathbf u \\&amp;= (I - \Delta R^T) \mathbf u + (\Delta R - I)\mathbf u \\&amp;= (\Delta R - \Delta R^T)\mathbf u \\&amp; = 0\end{aligned}$$&lt;p&gt;
In addition, a cross product of a vector with itself is equal to $0$, that is $\mathbf u \times \mathbf u = 0$, while the cross product can becomes the product for a vector $\mathbf u$ and its skew-symmetric matrix $S(\mathbf u)$ as shown in angular velocity. So we have
&lt;/p&gt;
$$(\Delta R - \Delta R^T)\mathbf u = S(\mathbf u)\mathbf u = \mathbf u \times \mathbf u = 0$$&lt;p&gt;
and $\mathbf u$ is derived from $S(\mathbf u)$ that is $\mathbf u = [r_{32} - r_{23}, r_{13} - r_{31}, r_{21} - r_{12}]^T$.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;While there are some special cases when $\Delta R$ is a diagonal matrix. Thus, for example, the rotation vector is calculated in a published paper&lt;sup id=&#34;fnref:4&#34;&gt;&lt;a href=&#34;#fn:4&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;, that is
&lt;/p&gt;
$$
a(\Delta R) = \begin{cases}
\frac{\pi}{2} \begin{bmatrix}r_{11} + 1 \\ r_{22} + 1 \\ r_{33} + 1 \end{bmatrix},&amp; (r_{11}, r_{22}, r_{33}) = (1, -1, -1) \text{ or }(-1, 1, -1)\text{ or }(-1, -1, 1) \\
\mathbf 0,&amp; (r_{11}, r_{22}, r_{33}) = (1, 1, 1) \\
\frac{atan2(\|\mathbf u\|, r_{11} + r_{22} + r_{33} - 1)}{\|\mathbf u\|} \mathbf u,&amp; \text{otherwise}
\end{cases}
$$&lt;p&gt;But, we should also notice that the position and orientation are commonly expressed using quaternions in computer programming, so the definition of $a(\cdot)$ may be different, like &lt;a href=&#34;https://math.stackexchange.com/questions/3572459/how-to-compute-the-orientation-error-between-two-3d-coordinate-frames&#34;&gt;this&lt;/a&gt;. Also, using some predefined tools is an alternative way to calculate the rotation vector, like &lt;code&gt;Rotation&lt;/code&gt; in &lt;code&gt;scipy.spatial.transform&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;newton-raphson-method-for-dik&#34;&gt;Newton-Raphson method for DIK&lt;/h2&gt;
&lt;p&gt;After defining $\mathbf e(\mathbf q)$, solving the equation $\mathbf e(\mathbf q) = 0$ is viewed as a root finding problem. Thus, &lt;a href=&#34;https://personal.math.ubc.ca/~anstee/math104/104newtonmethod.pdf&#34;&gt;Newton-Raphson method&lt;/a&gt; can be used. As the initial joint configuration is known, the error function can be expressed as
&lt;/p&gt;
$$
\begin{aligned}
\mathbf 0 &amp;= \mathbf e(\mathbf q) \\
&amp;= \mathbf e(\mathbf q_0 + \Delta \mathbf q)\\
&amp;\approx  \mathbf e(\mathbf q_0) +\nabla \mathbf e(\mathbf q_0)\Delta \mathbf q
\end{aligned}
$$&lt;p&gt;
by using the Taylor series expansion. The first derivative $\nabla \mathbf e(\mathbf q_0)$ is the Jacobian matrix $J(\mathbf q_0)$ with respect to the joint configuration&lt;sup id=&#34;fnref1:4&#34;&gt;&lt;a href=&#34;#fn:4&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;4&lt;/a&gt;&lt;/sup&gt;. So we have the $\Delta q = J^{-1}(\mathbf q_0)\mathbf e(\mathbf q_0)$ and the solution of $\mathbf q$ is&lt;/p&gt;
$$
\begin{aligned}
\mathbf q &amp;\approx \mathbf q_0 + \Delta \mathbf q \\
&amp;= \mathbf q_0 + J^{-1}(\mathbf q_0)\mathbf e(\mathbf q_0)
\end{aligned}
$$&lt;p&gt;
Actually, we widely use the Newton-Raphson iteration $\mathbf q_{k + 1} = \mathbf q_k + J^{-1}(\mathbf q_k)\mathbf e(\mathbf q_k)$ to find the desired joint configuration until $\mathbf e(q_{k + 1}) \le \epsilon$ where $\epsilon$ is a small positive constant.&lt;/p&gt;
&lt;p&gt;Obviously, there are some drawbacks, for example,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The Jacobian matrix is not always nonsingular.&lt;/li&gt;
&lt;li&gt;The error $\mathbf e(\mathbf q)$ is not always equal to $\mathbf 0$, because the robot cannot reach the target pose.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://www.rosroboticslearning.com/inverse-kinematics&#34;&gt;Inverse kinematics&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:2&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://motion.cs.illinois.edu/RoboticSystems/InverseKinematics.html&#34;&gt;Different approaches for solving inverse kinematics&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:3&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://en.wikipedia.org/wiki/Rotation_matrix#Determining_the_angle&#34;&gt;Rotation Matrix determining the angle&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:3&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&#34;fn:4&#34;&gt;
&lt;p&gt;Solvability-Unconcerned Inverse Kinematics by the Levenberg–Marquardt Method. Tomomichi Sugihara.&amp;#160;&lt;a href=&#34;#fnref:4&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref1:4&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Jacobian Matrix</title>
      <link>https://herding.github.io/posts/jacobian_matrix/</link>
      <pubDate>Sun, 08 Feb 2026 22:09:25 +0800</pubDate>
      
      <guid>https://herding.github.io/posts/jacobian_matrix/</guid>
      <description>&lt;p&gt;As shown in &lt;a href=&#34;https://herding.github.io/posts/homogeneous_transformation&#34;&gt;Homogeneous Transformation Matrices&lt;/a&gt;, the spatial configuration of the end effector can be expressed as
&lt;/p&gt;
$$
T = \begin{bmatrix}R^n_0&amp; \mathbf p^n_0\\ \mathbf 0&amp; 1\end{bmatrix} = A^1_0A^2_1\cdots A^n_{n - 1}.
$$&lt;p&gt;
Hence, angular velocity can be obtained from the time derivative of $R^n_0$&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; (see &lt;a href=&#34;https://herding.github.io/posts/angular_velocity&#34;&gt;Angular Velocity&lt;/a&gt;), giving
&lt;/p&gt;
$$
\begin{aligned}
\omega^n_0 &amp;= \omega^1_0 + R^1_0\omega^2_1 + R^2_0\omega^3_2 + \cdots R^{n - 1}_0 \omega^n_{n-1}\\
&amp;= \mathbf k \frac{d \theta_1}{d t} + R^1_0 \mathbf k \frac{d\theta_2}{dt} + R^2_0\mathbf k \frac{d\theta_3}{d t} + \cdots R^{n - 1}_0 \mathbf k \frac{d\theta_n}{dt} \\
&amp;= \begin{bmatrix}\mathbf \rho_1k,&amp; \rho_2R^1_0\mathbf k,&amp; \rho_3R^2_0\mathbf k,&amp; \cdots,&amp; \rho_nR^{n - 1}_0\mathbf k \end{bmatrix}\dot{\mathbf q}
\end{aligned}
$$&lt;p&gt;
where $\dot {\mathbf q} = \begin{bmatrix}\frac{d\theta_1}{dt},&amp;amp; \frac{d\theta_2}{dt},&amp;amp; \frac{d\theta_3}{dt},&amp;amp; \cdots,&amp;amp; \frac{d\theta_n}{dt}\end{bmatrix}^T$. $\rho_i = 1$ if the $i$th joint is revolute, otherwise $\rho_i = 0$.&lt;/p&gt;
&lt;p&gt;In the following, linear velocity is derived from the time derivative of $\mathbf p^n_0$&lt;sup id=&#34;fnref1:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;, and the Jacobian matrix is constructed from the angular and linear velocities.&lt;/p&gt;
&lt;h2 id=&#34;linear-velocity&#34;&gt;Linear velocity&lt;/h2&gt;
&lt;p&gt;Using the chain rule, the end effector&amp;rsquo;s linear velocity can be expressed as
&lt;/p&gt;
$$
\begin{aligned}
\dot {\mathbf p}^n_0 &amp;= \sum^n_{i = 1} \frac{\partial {\mathbf p}^n_0}{\partial q_i}\dot q_i \\
&amp;= \begin{bmatrix}\frac{\partial \mathbf p^n_0}{\partial q_1},&amp; \frac{\partial \mathbf p^n_0}{\partial q_2},&amp; \frac{\partial \mathbf p^n_0}{\partial q_3},&amp; \cdots,&amp;\frac{\partial \mathbf p^n_0}{\partial q_n}\end{bmatrix}\dot{\mathbf q}
\end{aligned}
$$&lt;p&gt;
where $\dot {\mathbf q}$ depends on the joint types. We therefore start from the general expression
&lt;/p&gt;
$$\mathbf p^n_0 = R^i_0\mathbf p^n_i + R^{i-1}_0 {\mathbf p}^i_{i-1} + {\mathbf p}^{i - 1}_0$$&lt;p&gt;
with motion produced by prismatic or revolute joints, derived from
&lt;/p&gt;
$$
\begin{aligned}
T &amp;= A^{i - 1}_0A^{i}_{i - 1}A^n_{i} \\
&amp;= \begin{bmatrix}R^{i-1}_0&amp; \mathbf p^{i - 1}_0 \\ \mathbf 0&amp; 1\end{bmatrix} \begin{bmatrix}R^{i}_{i - 1}&amp; \mathbf p^{i}_{i - 1} \\ \mathbf 0&amp; 1\end{bmatrix} \begin{bmatrix}R^{n}_{i}&amp; \mathbf p^{n}_{i} \\ \mathbf 0&amp; 1\end{bmatrix} \\
&amp;= \begin{bmatrix}R^{i}_0&amp; R^{i-1}_0\mathbf p^i_{i-1} + \mathbf p^{i - 1}_0 \\ \mathbf 0&amp; 1\end{bmatrix}\begin{bmatrix}R^{n}_{i}&amp; \mathbf p^{n}_{i} \\ \mathbf 0&amp; 1\end{bmatrix}  \\
&amp;= \begin{bmatrix}R^n_0&amp; R^i_0\mathbf p^n_i + R^{i-1}_0\mathbf p^i_{i-1} + \mathbf p^{i - 1}_0 \\ \mathbf 0&amp; 1\end{bmatrix}.
\end{aligned}
$$&lt;p&gt;
First, consider the $i$th joint to be prismatic. The rotation matrix and position vector of the $(i-1)$th frame are:
&lt;/p&gt;
$$
\begin{aligned}
&amp;R^i_{i - 1} = \begin{bmatrix}
1&amp; 0&amp; 0\\ 0&amp; 1&amp; 0 \\ 0&amp; 0&amp; 1
\end{bmatrix}, \\
&amp;
\mathbf p^i_{i - 1} = \begin{bmatrix}a_i \\0\\ d_i\end{bmatrix}.
\end{aligned}
$$&lt;blockquote&gt;
&lt;p&gt;HINT:&lt;/p&gt;
&lt;p&gt;According to the definition of homogeneous transformation matrix, $A^i_{i -1}$ is
&lt;/p&gt;
$$ \begin{aligned} A^{i}_{i - 1}  &amp;= Rot(z, 0)Trans(0, 0,d_i)Trans(a_i, 0, 0)Rot(x, 0) \\ &amp;= \begin{bmatrix}1&amp; 0&amp; 0&amp; 0\\ 0&amp; 1&amp; 0&amp; 0 \\ 0&amp; 0&amp; 1&amp; 0\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix} \begin{bmatrix}1&amp; 0&amp; 0&amp; 0 \\ 0&amp; 1&amp; 0&amp; 0\\ 0&amp; 0&amp; 1&amp; d_i\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix} \begin{bmatrix}1&amp; 0&amp; 0&amp; a_i \\ 0&amp; 1&amp; 0&amp; 0\\ 0&amp; 0&amp; 1&amp; 0\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix} \begin{bmatrix}1&amp; 0&amp; 0&amp; 0\\ 0&amp; 1&amp; 0&amp; 0 \\ 0&amp; 0&amp; 1&amp; 0\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix} \\ &amp;= \begin{bmatrix} 1&amp; 0&amp; 0&amp; a_i \\0&amp; 1&amp; 0&amp; 0 \\ 0&amp; 0&amp; 1&amp; d_i \\ 0&amp; 0&amp; 0&amp; 1 \end{bmatrix} = \begin{bmatrix}R^i_{i - 1}&amp; \mathbf p^i_{i - 1} \\ \mathbf 0&amp; 1\end{bmatrix}. \end{aligned} $$&lt;/blockquote&gt;
&lt;p&gt;Let $q_i = d_i$. The partial derivative of $\mathbf p^n_0$ can then be written as
&lt;/p&gt;
$$
\begin{aligned}
\frac{\partial \mathbf p^n_0}{\partial q_i} &amp;= \frac{\partial R^i_0\mathbf p^n_i}{\partial q_i} + \frac{\partial R^{i - 1}_0\mathbf p^i_{i - 1}}{\partial q_i} + \frac{\partial \mathbf p^{i - 1}_0}{\partial q_i} \\
&amp;= R^{i - 1}_0 \frac{\partial \mathbf p^i_{i - 1}}{\partial q_i} \\
&amp;= R^{i - 1}_0 \begin{bmatrix}0 \\ 0 \\ \dot q_i\end{bmatrix} \\
&amp;= R^{i - 1}_0 \mathbf k \dot q_i
\end{aligned}
$$&lt;p&gt;
where the partial derivatives of $R^i_0\mathbf p^n_i$ and $\mathbf p^{i - 1}_0$ vanish because these quantities are constant and not affected by $q_i$.&lt;/p&gt;
&lt;p&gt;Next, consider the $i$th joint to be revolute, which yields
&lt;/p&gt;
$$
\begin{aligned}
&amp;R^i_{i - 1} = \begin{bmatrix}
\cos\theta_i&amp; -\sin\theta_i&amp; 0\\ \sin\theta_i&amp; \cos\theta_i&amp; 0 \\ 0&amp; 0&amp; 1
\end{bmatrix},
\\
&amp;\mathbf p^i_{i - 1} = \begin{bmatrix}a_i \cos \theta_i \\ a_i \sin \theta_i \\ 0\end{bmatrix}.
\end{aligned}
$$&lt;blockquote&gt;
&lt;p&gt;HINT:&lt;/p&gt;
&lt;p&gt;$A^i_{i - 1}$ is
&lt;/p&gt;
$$ \begin{aligned} A^{i}_{i - 1}  &amp;= Rot(z, \theta_i)Trans(0, 0, 0)Trans(a_i, 0, 0)Rot(x, 0) \\ &amp;= \begin{bmatrix}\cos \theta_i&amp; -\sin\theta_i&amp; 0&amp; 0\\ \sin \theta_i&amp; \cos \theta_i&amp; 0&amp; 0 \\ 0&amp; 0&amp; 1&amp; 0\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix} \begin{bmatrix}1&amp; 0&amp; 0&amp; 0 \\ 0&amp; 1&amp; 0&amp; 0\\ 0&amp; 0&amp; 1&amp; 0\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix} \begin{bmatrix}1&amp; 0&amp; 0&amp; a_i \\ 0&amp; 1&amp; 0&amp; 0\\ 0&amp; 0&amp; 1&amp; 0\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix} \begin{bmatrix}1&amp; 0&amp; 0&amp; 0\\ 0&amp; 1&amp; 0&amp; 0 \\ 0&amp; 0&amp; 1&amp; 0\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix} \\ &amp;= \begin{bmatrix} \cos\theta_i&amp; -\sin\theta_i&amp; 0&amp; a_i\cos\theta_i \\ \sin\theta_i&amp; \cos\theta_i&amp; 0&amp; a_i\sin\theta_i \\ 0&amp; 0&amp; 1&amp; 0 \\ 0&amp; 0&amp; 0&amp; 1 \end{bmatrix}. \end{aligned} $$&lt;/blockquote&gt;
&lt;p&gt;Thus, setting $q_i = \theta_i$ leads to:
&lt;/p&gt;
$$
\begin{aligned}
\frac{\partial \mathbf p^n_0}{\partial q_i} &amp;= \frac{\partial R^i_0\mathbf p^n_i}{\partial q_i} + \frac{\partial R^{i - 1}_0\mathbf p^i_{i - 1}}{\partial q_i} + \frac{\partial \mathbf p^{i - 1}_0}{\partial q_i} \\
&amp;= \frac{\partial R^i_0\mathbf p^n_i}{\partial q_i} + \frac{\partial R^{i - 1}_0\mathbf p^i_{i - 1}}{\partial q_i}.
\end{aligned}
$$&lt;p&gt;
Using the definition of angular velocity for the $i$th link, the first term becomes
&lt;/p&gt;
$$
\frac{\partial R^i_0\mathbf p^n_i}{\partial q_i} = S(R^{i - 1}_0 \dot q_i \mathbf k)R^i_0 \mathbf p^n_i.
$$&lt;p&gt;
The second term is
&lt;/p&gt;
$$
\begin{aligned}
\frac{\partial R^{i - 1}_0 \mathbf p^i_{i - 1}}{\partial q_i} &amp;= R^{i - 1}_0 \frac{\partial }{\partial q_i}\begin{bmatrix}a_i\cos\theta_i \\ a_i\sin \theta_i \\ 0 \end{bmatrix}\\
&amp;= R^{i - 1}_0\begin{bmatrix}-a_i\sin\theta_i \\ a_i\cos \theta_i \\ 0 \end{bmatrix} \dot q_i \\
&amp;= R^{i - 1}_0 \dot q_i (\mathbf k \times \mathbf p^i_{i -1})\\
&amp;= R^{i - 1}_0 (\dot q_i \mathbf k \times \mathbf p^i_{i -1}) \\
&amp;= R^{i - 1}_0 S(\dot q_i \mathbf k)\mathbf p^i_{i - 1} \\
&amp;= S(R^{i - 1}_0\dot q_i \mathbf k)R^{i - 1}_0 \mathbf p^i_{i - 1}.
\end{aligned}
$$&lt;blockquote&gt;
&lt;p&gt;HINTs:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;$[-a_i \sin \theta_i,\ a_i \cos\theta_i,\ 0]^T$ is the result of the cross product.&lt;/li&gt;
&lt;/ol&gt;
$$ \begin{aligned} \mathbf k \times \mathbf p^i_{i - 1} &amp;= \begin{bmatrix}0 \\ 0\\ 1\end{bmatrix} \times \begin{bmatrix}a_i \cos \theta_i \\ a_i \sin \theta_i \\ 0\end{bmatrix} \\ &amp;= \begin{bmatrix}0 * 0 - 1 * a_i\sin\theta_i \\ 1 * a_i \cos\theta_i - 0 * 0 \\ 0 * a_i \sin \theta_i - 0 * a_i \cos\theta_i \end{bmatrix} \\ &amp;= \begin{bmatrix}-a_i \sin \theta_i \\ a_i \cos\theta_i \\ 0\end{bmatrix}. \end{aligned} $$&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;
&lt;p&gt;According to the property of skew symmetric matrix, $S(\mathbf a)\mathbf p = \mathbf a \times \mathbf p, \forall \mathbf p = [p_x, p_y, p_z]$ where $\times$ means the cross product, we have  $\dot q_i \mathbf k \times \mathbf p^i_{i - 1} = S(\dot q_i \mathbf k) \mathbf p^i_{i - 1}$.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;By using the property of skew symmetric matrix again, that is $RS(\mathbf a)R^T\mathbf b = S(R\mathbf a)\mathbf b$, we have
&lt;/p&gt;
$$ \begin{aligned}R^{i - 1}_0 S(\dot q_i \mathbf k)\mathbf p^i_{i - 1} &amp;= R^{i - 1}_0 S(\dot q_i \mathbf k) {R^{i - 1}_0}^TR^{i - 1}_0\mathbf p^i_{i - 1} \\ &amp;= S(R^{i - 1}_0\dot q_i \mathbf k)R^{i - 1}_0 \mathbf p^i_{i - 1}. \end{aligned}$$&lt;/li&gt;
&lt;/ol&gt;&lt;/blockquote&gt;
&lt;p&gt;Combining the two terms gives
&lt;/p&gt;
$$
\begin{aligned}
\frac{\partial \mathbf p^n_0}{\partial q_i} &amp;= \frac{\partial R^i_0\mathbf p^n_i}{\partial q_i} + \frac{\partial R^{i - 1}_0\mathbf p^i_{i - 1}}{\partial q_i} \\
&amp;= S(R^{i - 1}_0 \dot q_i \mathbf k) R^i_0 \mathbf p^n_i + S(R^{i - 1}_0\dot q_i \mathbf k)R^{i - 1}_0 \mathbf p^i_{i - 1} \\
&amp;= S(R^{i - 1}_0\dot q_i \mathbf k) (R^i_0 \mathbf p^n_i + R^{i - 1}_0 \mathbf p^i_{i - 1}) \\
&amp;= \dot q_i R^{i - 1}_0 \mathbf k \times (\mathbf p^n_0 - \mathbf p^{i - 1}_0)
\end{aligned}
$$&lt;p&gt;
based on the skew-symmetric property $S(\mathbf a)\mathbf p = \mathbf a \times \mathbf p$.&lt;/p&gt;
&lt;p&gt;In summary, the linear velocity is given by
&lt;/p&gt;
$$
\begin{aligned}
\dot {\mathbf p}^n_0 &amp;= \begin{bmatrix}\frac{\partial \mathbf p^n_0}{\partial q_1},&amp; \frac{\partial \mathbf p^n_0}{\partial q_2},&amp; \frac{\partial \mathbf p^n_0}{\partial q_3},&amp; \cdots,&amp;\frac{\partial \mathbf p^n_0}{\partial q_n}\end{bmatrix}\dot{\mathbf q}, \\
\frac{\partial \mathbf p^n_0}{\partial q_i}&amp;= \begin{cases}
R^{i - 1}_0\mathbf k \times (\mathbf p^n_0 - \mathbf p^{i - 1}_0)&amp; \text{revolute joint,} \\
R^{i - 1}_0\mathbf k&amp; \text{prismatic}.
\end{cases}
\end{aligned}
$$&lt;h2 id=&#34;jacobian-matrix&#34;&gt;Jacobian Matrix&lt;/h2&gt;
&lt;p&gt;The Jacobian matrix maps joint velocities to the end effector&amp;rsquo;s velocities and is denoted by $J$. From the angular and linear velocity expressions, the relationship between the two spaces becomes
&lt;/p&gt;
$$
\begin{aligned}
\begin{bmatrix}
\mathbf v^n_0 \\
\mathbf \omega^n_0
\end{bmatrix} &amp;= 
\begin{bmatrix}
J_{\mathbf v} \\
J_{\mathbf \omega}
\end{bmatrix} \dot {\mathbf q}, \\
J_{\mathbf v} &amp;= \begin{bmatrix}\frac{\partial \mathbf p^n_0}{\partial q_1},&amp; \frac{\partial \mathbf p^n_0}{\partial q_2},&amp; \frac{\partial \mathbf p^n_0}{\partial q_3},&amp; \cdots,&amp;\frac{\partial \mathbf p^n_0}{\partial q_n}\end{bmatrix}, \\
J_{\omega} &amp;= \begin{bmatrix}\rho_1\mathbf k,&amp; \rho_2R^1_0\mathbf k,&amp; \rho_3R^2_0\mathbf k,&amp; \cdots,&amp; \rho_nR^{n - 1}_0\mathbf k \end{bmatrix}.
\end{aligned}
$$&lt;p&gt;
For a revolute $i$th joint,
&lt;/p&gt;
$$
\begin{aligned}
J_{\mathbf v_i} &amp;= R^{i - 1}_0\mathbf k \times (\mathbf p^n_0 - \mathbf p^{i - 1}_0), \\
J_{\omega_i} &amp;= R^{i - 1}_0\mathbf k.
\end{aligned}
$$&lt;p&gt;
For a prismatic $i$th joint,
&lt;/p&gt;
$$
\begin{aligned}
J_{\mathbf v_i} &amp;= R^{i - 1}_0\mathbf k, \\
J_{\omega_i} &amp;= 0.
\end{aligned}
$$&lt;p&gt;
In principle, given a desired change in end‑effector position and orientation one could compute a corresponding change in joint configuration by inverting $J$, i.e. $J^{-1}[\Delta \mathbf v^n_0, \Delta \omega^n_0]^T$. However, in practice this inversion is often difficult for various reasons.&lt;/p&gt;
&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id=&#34;fn:1&#34;&gt;
&lt;p&gt;&lt;a href=&#34;https://thydzik.com/academic/robotics-315/chap5.pdf&#34;&gt;https://thydzik.com/academic/robotics-315/chap5.pdf&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&amp;#160;&lt;a href=&#34;#fnref1:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Angular Velocity</title>
      <link>https://herding.github.io/posts/angular_velocity/</link>
      <pubDate>Thu, 05 Feb 2026 09:48:33 +0800</pubDate>
      
      <guid>https://herding.github.io/posts/angular_velocity/</guid>
      <description>&lt;p&gt;The relationship between the spatial pose of the end-effector and joint configurations is introduced in &lt;a href=&#34;https://herding.github.io/posts/homogeneous_transformation&#34;&gt;Homogeneous Transformation Matrix&lt;/a&gt;. Here we derive the relationships between the end-effector velocities and the joint velocities. When discussing end-effector velocities in Cartesian space, there are both linear velocities (translation) and angular velocities (rotation). This post introduces the definition of angular velocity and the time derivative of rotation matrices.&lt;/p&gt;
&lt;h2 id=&#34;angular-velocities&#34;&gt;Angular Velocities&lt;/h2&gt;
&lt;p&gt;Because the end-effector&amp;rsquo;s pose includes orientation, recall the definition of angular velocity $\omega = d\theta / dt \cdot \mathbf u$ when computing velocities. Angular velocity is a pseudovector as shown in the figure. Its direction depends on the unit vector $\mathbf u$ and is perpendicular to the plane swept by the position vector $\mathbf r$; it is parallel to the rotation axis with magnitude $d\theta / dt$ (radians per unit time).&lt;/p&gt;











&lt;figure class=&#34;site-figure center&#34;&gt;
  
    
    
      
      
      
      
      
        
        
      
        
        
      
      
      
      
      
      
      &lt;img src=&#34;https://herding.github.io/posts/angular_velocity/Velocity_hu_57ffbb0825710b03.png&#34; srcset=&#34;https://herding.github.io/posts/angular_velocity/Velocity_hu_50699b98dbce63b3.png 420w, https://herding.github.io/posts/angular_velocity/Velocity_hu_57ffbb0825710b03.png 840w&#34; sizes=&#34;(max-width: 420px) 100vw, 420px&#34; alt=&#34;allocation&#34; ZgotmplZ&gt;
    
  
    &lt;figcaption&gt;From Wikipedia&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;To fix the direction of angular velocity, we use the right-hand rule. Point the index finger along the position vector $\mathbf r$, the middle finger along the instantaneous linear velocity $\mathbf v_{\omega}$, and the thumb then points in the direction of the angular velocity. Viewed from the tip of $\mathbf u$, the rotation appears counter-clockwise.&lt;/p&gt;
&lt;h2 id=&#34;the-derivative-of-rotation-matrix&#34;&gt;The Derivative of Rotation Matrix&lt;/h2&gt;
&lt;p&gt;The orientation of the end-effector is expressed as a rotation matrix $R$ in forward kinematics; therefore angular velocity can be related to the time derivative of $R$ via
&lt;/p&gt;
$$
\frac{dR^n_0(\theta)}{dt} = \frac{dR^n_0(\theta)}{d\theta} \frac{d\theta}{dt}
$$&lt;p&gt;
To obtain angular velocity from a rotation matrix, consider the simple case of a rotation about the $x$-axis and derive the derivative of the rotation matrix with respect to time:
&lt;/p&gt;
$$
\frac{d R(x, \theta)}{dt} = \frac{dR(x, \theta)}{d \theta}\frac{d\theta}{dt}.
$$&lt;p&gt;
Now consider how to compute $dR(x, \theta)/d\theta$. Some properties of skew-symmetric matrices are useful; if you are already familiar with them you can skip this section.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;HINTS of Skew-Symmetric Matrices&lt;/p&gt;
&lt;p&gt;Definition: A matrix $S$ is skew-symmetric if and only if $S + S^T = 0$, i.e. $s_{ij} = -s_{ji}$.&lt;/p&gt;
&lt;p&gt;Properties:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;$S(a \mathbf a + b \mathbf b) = aS(\mathbf a) + bS(\mathbf b), \forall \mathbf a, \mathbf b \in \mathbb R^3$;&lt;/li&gt;
&lt;li&gt;$S(\mathbf a)\mathbf p = \mathbf a \times \mathbf p, \forall \mathbf p = [p_x, p_y, p_z]^T$, where $\times$ denotes the &lt;a href=&#34;https://en.wikipedia.org/wiki/Cross_product&#34;&gt;cross product&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;$R(\mathbf a \times \mathbf b) = R\mathbf a \times R\mathbf b$ for $R\in SO(3)$ (the 3D rotation group);&lt;/li&gt;
&lt;li&gt;$RS(\mathbf a)R^T\mathbf b = R(\mathbf a \times R^T \mathbf b) = (R\mathbf a) \times \mathbf b = S(R\mathbf a)\mathbf b$;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;where $\mathbf a = [a_x, a_y, a_z]^T$ is a vector. The skew-symmetric matrix $S(\mathbf a)$ is defined as
&lt;/p&gt;
$$ S(\mathbf a) = \begin{bmatrix}0&amp; -a_z&amp; a_y \\\ a_z&amp; 0&amp; -a_x\\ -a_y&amp; a_x&amp; 0\end{bmatrix}. $$&lt;/blockquote&gt;
&lt;p&gt;Because $R(x, \theta)$ belongs to the 3D rotation group $SO(3)$, it is orthogonal, so
&lt;/p&gt;
$$
R(x, \theta)R^T(x, \theta) = I.
$$&lt;p&gt;
Using the product rule, the derivative of the above equation is
&lt;/p&gt;
$$
\frac{dR(x, \theta)}{d\theta}R^T(x, \theta) + R(x, \theta)\frac{dR^T(x, \theta)}{d\theta} = 0
$$&lt;p&gt;
According to the definition of a skew-symmetric matrix, let $S = R^T(x, \theta) \cdot dR(x, \theta) / d\theta$. It can be simplified using the derivative and transpose of $R(x, \theta)$ as shown in the homogeneous transformation matrix:
&lt;/p&gt;
$$
\begin{aligned}
S = \frac{dR(x, \theta)}{d\theta}R(x, \theta)^T &amp;= \begin{bmatrix}0&amp; 0&amp; 0\\ 0&amp; -\sin \theta&amp; -\cos\theta\\ 0&amp; \cos\theta&amp; -\sin\theta\end{bmatrix} \begin{bmatrix}1&amp; 0&amp; 0\\ 0&amp; \cos\theta&amp; \sin\theta\\ 0&amp; -\sin\theta&amp; \cos\theta\end{bmatrix} \\\ 
&amp;= \begin{bmatrix}0&amp; 0&amp; 0\\ 0&amp; 0&amp; -1\\ 0&amp; 1&amp; 0\end{bmatrix} \\\ 
&amp;= S(\mathbf i)
\end{aligned}
$$&lt;p&gt;
where $\mathbf i = [1, 0, 0]^T$ is the unit vector along the $x$-axis. Thus $dR(x, \theta)/d\theta = S(\mathbf i)R(x, \theta)$. The time derivative $dR(x, \theta)/dt$ can then be expressed as
&lt;/p&gt;
$$
\begin{aligned}
\frac{d R(x, \theta)}{dt} &amp;= \frac{d R(x, \theta)}{d\theta}\frac{d\theta}{dt} \\\ 
&amp;= \frac{d\theta}{dt} S(\mathbf i)R(x, \theta) \\\ 
&amp;= S\Big(\frac{d\theta}{dt} \mathbf i\Big)R(x, \theta) \\\ 
&amp;= S(\omega)R(x, \theta)
\end{aligned}
$$&lt;p&gt;
where $\omega$ is the angular velocity. Similarly, derivatives of rotation matrices about the $y$- or $z$-axes satisfy $dR(y, \theta)/d\theta = S(\mathbf j)R(y, \theta)$ and $dR(z, \theta)/d\theta = S(\mathbf k)R(z, \theta)$, where $\mathbf j = [0,1,0]^T$ and $\mathbf k = [0,0,1]^T$. In this example the angular velocity vector points along the rotation axis with magnitude $d\theta/dt$.&lt;/p&gt;
&lt;p&gt;More generally, the time derivative of a rotation matrix $R^2_0(\theta)$ for an end-effector with two intermediate frames is
&lt;/p&gt;
$$
\begin{aligned}
\dot{R}^2_0 &amp;= \dot{R}^1_0 R^2_1 + R^1_0\dot{R}^2_1 \\\ 
&amp;= S(\omega^1_0)R^1_0R^2_1 + R^1_0S(\omega^2_1)R^2_1 \\\ 
&amp;= S(\omega^1_0)R^1_0R^2_1 + R^1_0 S(\omega^2_1) {R^1_0}^T R^1_0 R^2_1(t) \\\ 
&amp;= S(\omega^1_0)R^1_0R^2_1 + S(R^1_0(t)\omega^2_1(t))R^1_0(t)R^2_1(t) \\\ 
&amp;= S(\omega^1_0 + R^1_0 \omega^2_1) \cdot R^2_0 \\\ 
&amp;= S(\omega^2_0) R^2_0
\end{aligned}
$$&lt;p&gt;
by using the first and fourth properties of skew-symmetric matrices. The combined angular velocity results from the individual frame rotations. Similarly, we obtain
&lt;/p&gt;
$$
\begin{aligned}
\dot R^n_0 &amp;= S\big(\omega^n_0\big)R^n_0 \\\ 
\\
\omega^n_0 &amp;= \omega^1_0 + R^1_0\omega^2_1 + R^2_0\omega^3_2 + \cdots + R^{n - 1}_0\omega^n_{n - 1}
\end{aligned}
$$&lt;p&gt;
where $\omega^n_0$ is the desired angular velocity of the end-effector.&lt;/p&gt;
&lt;p&gt;In conclusion, the time derivative of a rotation matrix can be expressed using skew-symmetric matrices and the angular velocities of individual frames. This relationship is commonly used when deriving the Jacobian matrix based on $\omega^n_0$.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Homogeneous Transformation Matrices</title>
      <link>https://herding.github.io/posts/homogeneous_transformation/</link>
      <pubDate>Sun, 25 Jan 2026 11:51:56 +0800</pubDate>
      
      <guid>https://herding.github.io/posts/homogeneous_transformation/</guid>
      <description>&lt;p&gt;This article explains how to construct transformation matrices using the parameters obtained from the &lt;a href=&#34;https://herding.github.io/posts/dh_convention&#34;&gt;DH convention&lt;/a&gt;, and how to determine the spatial position and orientation of the end-effector through algebraic calculations.&lt;/p&gt;
&lt;h2 id=&#34;translation-matrices&#34;&gt;Translation Matrices&lt;/h2&gt;
&lt;p&gt;First, consider a general spatial translation. The position after translation can be described as:
&lt;/p&gt;
$$
\begin{cases}
x&#39; = x + t_x \\
y&#39; = y + t_y \\
z&#39; = z + t_z
\end{cases}
$$&lt;p&gt;where $x, y, z$ represent the original position, and $t_x, t_y, t_z$ represent the translation distances along different directions. Using matrix notation, this becomes:
&lt;/p&gt;
$$
\begin{bmatrix}x&#39; \\ y&#39;\\ z&#39;\\ 1\end{bmatrix} = \begin{bmatrix}1&amp; 0&amp; 0&amp; t_x\\ 0&amp; 1&amp; 0&amp; t_y\\ 0&amp; 0&amp; 1&amp; t_z\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix}\begin{bmatrix}x \\ y\\ z\\ 1\end{bmatrix}
$$&lt;p&gt;The $4 \times 4$ matrix is the translation matrix $Trans(t_x, t_y, t_z)$, an augmented matrix representing affine transformation in homogeneous coordinates. Recall the translation matrices $Trans(0, 0, d_i)$ and $Trans(a_i, 0, 0)$ from the DH convention, which represent displacements of $d_i$ and $a_i$ along the $z$ and $x$ axes respectively.&lt;/p&gt;
&lt;h2 id=&#34;rotation-matrices&#34;&gt;Rotation Matrices&lt;/h2&gt;
&lt;p&gt;In addition to spatial translation, rotation of a point in space must also be described by matrices. Starting with rotation by $0°$ (no rotation), the rotation matrix is defined as:
&lt;/p&gt;
$$
Rot(x, 0) = \begin{bmatrix}
\cos 0°&amp; \cos 90°&amp; \cos 90°&amp; 0\\ \cos 90°&amp; \cos 0°&amp; \cos 90°&amp; 0 \\ \cos 90°&amp; \cos 90°&amp; \cos 0°&amp; 0\\ 0&amp; 0&amp; 0&amp; 1
\end{bmatrix}
= \begin{bmatrix}1&amp; 0&amp; 0&amp; 0\\ 0&amp; 1&amp; 0&amp; 0\\ 0&amp; 0&amp; 1&amp; 0\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix}
$$&lt;p&gt;The first three rows represent the $x, y, z$ axes, while the first three columns represent the transformed $x&amp;rsquo;, y&amp;rsquo;, z&amp;rsquo;$ axes. The angle between $x$ and $x&amp;rsquo;$ is $0°$, while the angles between $x$ and $y&amp;rsquo;, z&amp;rsquo;$ are both $90°$. Comparing translation and rotation matrices, we observe that the $3 \times 3$ submatrix (formed by the first three rows and columns) describes rotation, the first three elements of the fourth column describe translation, and the rest is the augmentation for computational consistency.&lt;/p&gt;
&lt;h3 id=&#34;rotation-around-the-x-axis&#34;&gt;Rotation around the X-axis&lt;/h3&gt;
&lt;p&gt;When a point rotates by angle $\alpha$ around the $x$-axis, the rotation is described as:
&lt;/p&gt;
$$
Rot(x, \alpha) = \begin{bmatrix}
\cos 0°&amp; \cos 90°&amp; \cos 90°&amp; 0\\ \cos 90°&amp; \cos \alpha&amp; \cos (90°+\alpha)&amp; 0 \\ \cos 90°&amp; \cos (90°- \alpha)&amp; \cos \alpha&amp; 0\\ 0&amp; 0&amp; 0&amp; 1
\end{bmatrix} = \begin{bmatrix}1&amp; 0&amp; 0&amp; 0\\ 0&amp; \cos \alpha&amp; -\sin\alpha&amp; 0 \\ 0&amp; \sin\alpha&amp; \cos \alpha&amp; 0\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix}
$$&lt;p&gt;After rotation, the relationship between the $x$-axis and the $x&amp;rsquo;, y&amp;rsquo;, z&amp;rsquo;$ axes remains unchanged. The angle between $y&amp;rsquo;$ and the original $y$, and between $z$ and $z&amp;rsquo;$, both rotate by $\alpha$. The angle between $y$ and $z&amp;rsquo;$ becomes $90° + \alpha$, while the angle between $y&amp;rsquo;$ and $z$ becomes $90° - \alpha$.&lt;/p&gt;











&lt;figure class=&#34;site-figure center&#34;&gt;
  
    
    
      
      
      
      
      
        
        
      
        
        
      
      
      
      
      
      
      &lt;img src=&#34;https://herding.github.io/posts/homogeneous_transformation/Rotation_hu_fbe3a852d5993000.png&#34; srcset=&#34;https://herding.github.io/posts/homogeneous_transformation/Rotation_hu_6cbb9efd39ef193e.png 600w, https://herding.github.io/posts/homogeneous_transformation/Rotation_hu_fbe3a852d5993000.png 1200w&#34; sizes=&#34;(max-width: 600px) 100vw, 600px&#34; alt=&#34;allocation&#34; ZgotmplZ&gt;
    
  
    &lt;figcaption&gt;From Homogenous Transformation Matrices. Matjaž Mihelj and so on. 2019.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h3 id=&#34;rotation-around-the-y-and-z-axes&#34;&gt;Rotation around the Y and Z axes&lt;/h3&gt;
&lt;p&gt;Similarly, rotation by $\beta$ around the $y$-axis and by $\gamma$ around the $z$-axis are expressed as:
&lt;/p&gt;
$$
Rot(y, \beta) = \begin{bmatrix}\cos \beta&amp; 0&amp; \sin\beta&amp; 0\\ 0&amp; 1&amp; 0&amp; 0 \\ -\sin\beta&amp; 0&amp; \cos \beta&amp; 0\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix}, \quad Rot(z, \gamma) = \begin{bmatrix}\cos \gamma&amp; -\sin\gamma&amp; 0&amp; 0\\ \sin\gamma&amp; \cos\gamma&amp; 0&amp; 0 \\ 0&amp; 0&amp; 1&amp; 0\\ 0&amp; 0&amp; 0&amp; 1\end{bmatrix}
$$&lt;h2 id=&#34;link-transformation-matrices&#34;&gt;Link Transformation Matrices&lt;/h2&gt;
&lt;p&gt;The process described above shows how to convert basic translation and rotation operations into matrices, and how the spatial relationship between two rigid bodies can be represented through such transformations. Relative to link $i-1$, the position of link $i$ is transformed by:
&lt;/p&gt;
$$
A_{i - 1}^i = Rot(z, \theta_i)Trans(0, 0, d_i)Trans(a_i, 0, 0) Rot(x, \alpha_i)
$$&lt;h2 id=&#34;forward-kinematics&#34;&gt;Forward Kinematics&lt;/h2&gt;
&lt;p&gt;Finally, based on the coordinate frames and parameters determined by the DH convention for each link, and the transformation matrices between links, we can obtain the position and orientation of the end-effector in the base space. This is achieved through matrix multiplication, mapping the end-effector information to the base frame:
&lt;/p&gt;
$$
T = A_0^1A_1^2\cdots A_{n - 1}^n
$$</description>
    </item>
    
  </channel>
</rss>
