As a personal brain exercise, I've recently been trying to work out the math involved with rotating vertices around an arbitrary axis in 3D space.

To do so, I've been relying very heavily on the following page:

Conceptually, I get everything, but now, I want to verify everything in the link above by doing the math necessary to work out the matrix that results from Txz-1, Tz-1, Rz(θ), Tz, Txz (please see section 5.1 in the link above).
The link above shows the matrices used for Txz, Tz and Rz(θ), and I was able to get the matrices required for Txz-1 and Tz-1 thanks to everyone's help here on this question:
How do I calculate the inverse of these matrices?

At this point, I have all five matrices I need, but I have to admit, as I start doing the matrix multiplication, things get way too hairy for me to handle real quick.
I have tried several times to first multiple Tx by Txz, then multiply the product of that by Rz(θ), and then multiple the product of that by Tz-1, and finally multiply the product of that by Txz-1, but I can't seem to get even remotely close to the matrix shown in section 5.1.

One technique I tried was substituting A for sqrt(u^2 + v^2) and B for sqrt(u^2 + v^2 + w^2), but even so, the math was too much for me to handle.

Could someone please offer me some advice for how to multiply these five matrices together so that I can confirm the result shown in section 5.1 in the link above?

Thank you very much.


1 Answer 1


There are simpler algorithms. Suppose the axis of rotation is defined as the vector from $\vec{v_{0}}$ to $\vec{v_{1}}$. Normalize this vector to a unit vector $\vec{u_{1}}$: $$ \vec{u_{1}}=\frac{1}{|\vec{v_{1}}-\vec{v_{0}}|}(\vec{v_{1}}-\vec{v_{0}}). $$ Suppose $\vec{u_{1}}=(u_{1,1},u_{1,2},u_{1,3})$. You can easily find a unit vector $\vec{u_{2}}$ which is orthogonal to $\vec{u_{1}}$. For example, if $u_{1,1}=0$, then $\vec{u_{2}}=(1,0,0)$ works; otherwise $\vec{u_{2}}=\frac{1}{\sqrt{u_{1,1}^{2}+u_{1,2}^{2}}}(-u_{1,2},u_{1,1},0)$ works. Define the third vector as a cross-product in such a way that you end up with a right-hand triple: $$ \vec{u_{3}}=\vec{u_{1}}\times\vec{u_{2}}. $$ A standard counter-clockwise rotation matrix $R(\theta)$ about the origin in the $x$-$y$ plane maps the unit vector $\hat{x}$ to $\cos\theta\; \hat{x}+\sin\theta \;\hat{y}$, and maps $\hat{y}$ to $-\sin\theta\;\hat{x}+\cos\theta\;\hat{y}$. A rotation matrix around $\vec{u_{1}}$ performs the following mappings: $$ \vec{u_{2}} \mapsto\cos\theta\; \vec{u_{2}}+\sin\theta\;\vec{u_{3}} \\ \vec{u_{3}} \mapsto -\sin\theta\vec{u_{2}}+\cos\theta\vec{u_{3}}. $$

So, here's the final implementation of the transformation you want ($\cdot$ denotes dot product): $$ \begin{align} R_{v_{0},v_{1}}(\theta)\vec{x} & = \left[(\vec{x}-\vec{v_{0}})\cdot\vec{u_{1}}\right]\vec{u_{1}} \\ & +\left[(\vec{x}-\vec{v_{0}})\cdot\vec{u_{2}}\right](\cos\theta\vec{u_{2}}+\sin\theta \vec{u_{3}}) \\ & +\left[(\vec{x}-\vec{v_{0}})\cdot\vec{u_{3}}\right](-\sin\theta\vec{u_{2}}+\cos\theta\vec{u_{3}})+\vec{v_{0}}. \end{align} $$ This can be written as a matrix transformation using vector components $$ \left[\begin{matrix} u_{1,1} & u_{2,1} & u_{3,1} \\ u_{1,2} & u_{2,2} & u_{3,2} \\ u_{1,3} & u_{2,3} & u_{3,3} \end{matrix}\right] \left[\begin{matrix} 1 & 0 & 0 \\ 0 & \cos\theta & -\sin\theta \\ 0 & \sin\theta & \cos\theta \end{matrix}\right] \left[\begin{matrix} u_{1,1} & u_{1,2} & u_{1,3} \\ u_{2,1} & u_{2,2} & u_{2,3} \\ u_{3,1} & u_{3,2} & u_{3,3} \end{matrix}\right] \left(\left[\begin{matrix}x_{1}\\x_{2}\\x_{3}\end{matrix}\right] -\left[\begin{matrix}v_{0,1}\\v_{0,2}\\v_{0,3}\end{matrix}\right]\right) + \left[\begin{matrix}v_{0,1}\\v_{0,2}\\v_{0,3}\end{matrix}\right] $$ You can easily add the fourth-dimension in order to absorb translation.

  • $\begingroup$ T.A.E., I don't get it. I have no doubt that what you say is correct, but I can't understand any of it. I don't see the connection between what you explained and the question I asked, nor do I see why your method is easier than just multiplying the five matrices out. Could you please provide some more explanation? Thanks. $\endgroup$
    – HartleySan
    Apr 14, 2014 at 1:24
  • $\begingroup$ I have given you the full description of a method. Have you compared the complexity of this with what you have referenced? Plus, what I have given you uses familiar $\mathbb{R}^{3}$ tools from calculus. In fact, you don't really need to use the matrices at the end at all. Just use the algorithm above it. Once you construct $\vec{u_{1}},\vec{u_{2}},\vec{u_{3}}$, everything else involves (a) vector addition/subtraction (b) scalar multiplication of a vector (c) dot product. The algorithm is simple enough that bothering with a final matrix form isn't critical. $\endgroup$ Apr 14, 2014 at 4:06
  • $\begingroup$ My understanding of math isn't nearly what yours is. As such, I can't understand most of the symbols you are using. I don't even know what those symbols are called, so I can't even search for them on Google to learn more about them. More than anything though, I was hoping for some guidance in using the matrices in sections 3 and 4 in the link in my post to derive the matrix in section 5.1. That's all. I do trust there are "easier" ways to get there, but I really just wanted to know how the author of the linked article arrived at the matrix in 5.1 Thanks. $\endgroup$
    – HartleySan
    Apr 16, 2014 at 2:58
  • $\begingroup$ Normally someone encounters vector calculus before matrices and linear algebra. So you don't know about 3d vectors, dot product, and cross product? That's what I am using. If you haven't seen those things, then my solution isn't going to make sense to you. $\endgroup$ Apr 16, 2014 at 3:29
  • $\begingroup$ I know about 3D vectors, dot products and cross products. Also, I understand how to calculate a unit vector, how to calculate a vector orthogonal to that unit vector, and what the cross product of those two vectors means. What I don't understand is why we bother doing any of this for the question I asked, or how this gets us the same answer as multiplying a bunch of matrices together to calculate the rotation of vertices along an arbitrary axis. Also, your answer lost me from "A standard counter-clockwise rotation matrix R(θ) ..." on. I'm sorry, but is there an easier or more complete answer? $\endgroup$
    – HartleySan
    Apr 16, 2014 at 4:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .