3
$\begingroup$

For a certain software that I'm developing, I need to create a rotation matrix for a custom axis, and being almost completely self-taught in math, I am trying to wrap my mind around it, yet failing horribly. This is the simple rotation matrix for rotation along Z axis: $$\begin{pmatrix} \cos\theta& -\sin\theta& 0\\ \sin\theta& \cos\theta& 0\\ 0& 0& 1 \end{pmatrix}$$ Can someone explain how to I modify this matrix for use with a custom axis, which is offset from the Z axis by n degrees (and on the YZ plane)? I went at this problem for 2 days now, and I still can't solve it, no matter how many times I read the wiki article about rotation matrices... Attaching a picture to help you visualize the problem. Thank you in advance.

enter image description here

$\endgroup$
  • $\begingroup$ en.wikipedia.org/wiki/Rodrigues%27_rotation_formula $\endgroup$ – Giuseppe Negro Sep 22 '18 at 17:01
  • $\begingroup$ Thank you for that link, Giuseppe, but that stuff is way over my understanding. Wouldn't it be too much for me to ask how do I apply it to my described issue? $\endgroup$ – Justinas Rubinovas Sep 22 '18 at 17:41
  • $\begingroup$ There's an explicit formula in the second section, just apply that, forget about the Lie group and matrix exponential stuff $\endgroup$ – Giuseppe Negro Sep 22 '18 at 17:42
  • $\begingroup$ In the "Statement" section $\endgroup$ – Giuseppe Negro Sep 22 '18 at 17:43
1
$\begingroup$

In general, the result of rotating a vector $\mathbf v$ about an axis $\mathbf k$ (expressed as a unit vector) by an angle $\theta$ is given by the Rodrigues rotation formula: $$ \mathbf v' = \mathbf v \cos\theta + (\mathbf k \times \mathbf v)\sin \theta + \mathbf k(\mathbf k \cdot \mathbf v)(1-\cos \theta).$$ In your case you have $\mathbf k = (0, \sin n, \cos n)$. To compute the rotation matrix, we can use the above formula to compute $\mathbf v'$ in the case of $\mathbf v$ being each of the standard basis vectors $\mathbf e_1=(1,0,0)$, $\mathbf e_2=(0,1,0)$, and $\mathbf e_3 =(0,0,1)$. Stacking these results side-by-side as column vectors will gives us the $3 \times 3$ rotation matrix. Explicitly,

$$\begin{bmatrix}\cos \theta &-\cos n\sin \theta &\sin n\sin \theta \\ \cos n\sin \theta & (1-\cos \theta)(\sin n)^2 + \cos\theta & (1-\cos \theta)\cos n\sin n \\ -\sin n\sin\theta & (1- \cos\theta)\cos n\sin n & (1-\cos\theta)(\cos n)^2 + \cos\theta \end{bmatrix}$$

$\endgroup$
  • $\begingroup$ Or one could go directly to the matrix form of Rodrigues' formula. $\endgroup$ – amd Sep 22 '18 at 19:13
  • $\begingroup$ Thank you for your answer. So, just to be sure, this matrix is multiplied traditionally when determining new x', y' and z', like x' = x cosθ - y cos n sin θ + z sin n sin θ, correct? $\endgroup$ – Justinas Rubinovas Sep 22 '18 at 21:07
  • $\begingroup$ Yes, that's right. $\endgroup$ – Brent Kerby Sep 23 '18 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.