Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given angles (in degrees) to rotate around, $x$-, $y$-, $z$-axis how does one come up with the rotation matrix? For example if you have a point $p$ represented by a vector, how do you rotate it by multiplying it with a matrix $A$ so $p = Ap$.

From Wikipedia:

A basic rotation (also called elemental rotation) is a rotation about one of the axes of a coordinate system. The following three basic rotation matrices rotate vectors by an angle $\theta$ about the $x$, $y$, or $z$ axis, in three dimensions:

rotation matrices

I'm a little unclear. So you need a different rotation matrix for each one of the axis? Is there a way just to get one rotation matrix that covers the rotations done to each axis? Am I even reading this right, so $R_x(\theta)$ is the matrix used to perform the rotation about the $x$-axis for $\theta$ degrees?

share|cite|improve this question
@NotMe I'm really new at this and if you could elaborate that would be great. See my edit for where I'm confused. – Celeritas Jan 26 '14 at 0:23
up vote 2 down vote accepted

If $R_x$ rotates around the $x$-axis, and $R_y$ rotates around the $y$-axis, and you want to rotate first around $x$, and then around $y$, simply apply $R_y R_x$ to your vector, let's call it $v$.

This is because $R_x v$ rotates $v$ around the $x$-axis, then $R_y(R_x v)$ rotates $R_x v$ around the $y$-axis.

share|cite|improve this answer
Since matrix multiplication is associative I can just multiply $R_yR_x$ and multiply the resulting matrix by the vector, right? – Celeritas Jan 26 '14 at 0:29
Yes, indeed!${}{}$ – Emily Jan 26 '14 at 1:36
then angle theta changes for each one of the rotation matrices, right? rotating 45 deg around x-axis and 90 deg around y-axis then the theta used in cos and sin for $R_x$, $R_y$ and $R_z$ are different, right? – Celeritas Jan 28 '14 at 9:39
Yes... $R_x(\theta)$, $R_y(\phi)$, $R_z(\psi)$, etc... – Emily Jan 28 '14 at 15:36

The easiest way is to think in polar coordinates. I'll do a case in $\mathbb{R}^2$..

Let $P = (x,y)$, and $P_\varphi = (x_\varphi, y_\varphi)$ the same point rotated by $\varphi$ degrees (or radians, whatever). We write $x = r \cdot \cos \theta$ and $y = r \cdot \sin \theta$, where $\theta$ is the angle formed between the vector $\vec{OP}$ and the $x$ axis, and $r$ is the distance of $P$ to the origin. Now, we have $P = (r \cdot \cos \theta, r \cdot \sin \theta)$. It should be intuitive now that $$P_\varphi = (r \cdot \cos(\theta + \varphi), r \cdot \sin(\theta + \varphi))$$ Using the formulas for angle addition, follows that $$P_\varphi = (r \cdot (\cos\theta \cdot \cos\varphi - \sin\theta \cdot \sin \varphi), \hspace{3pt} r \cdot (\sin\theta \cdot \cos \varphi + \cos \theta \cdot \sin \varphi)) \\ P_\varphi = (r \cdot \cos\theta \cdot \cos\varphi - r \cdot \sin\theta \cdot \sin \varphi, \hspace{3pt} r \cdot \sin \theta \cdot \cos \varphi + r \cdot \cos \theta \cdot \sin \varphi) \\ P_\varphi = (x \cdot \cos \varphi - y \cdot \sin\varphi, \hspace{3pt} y \cdot \cos \varphi + x \cdot \sin \varphi)$$

So, basically, we apply this last formula to the points $(1,0)$ and $(0,1)$. Denoting by $T_\varphi(x,y)$ the rotation, we get $T_\varphi(1,0)= (\cos \varphi, \sin \varphi)$ (this will be the first column!), and $T_\varphi(0,1) = (- \sin \varphi, \cos \varphi)$ (this is the second column!). I'm having trouble to write the matrix here, but I hope you got the idea.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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