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

Main question

Let ($x_p$, $y_p$, $z_p$) be the initial coordinates of a point $P$ on a rigid body in a right-handed 3D Euclidean space. Let ($x_r$, $y_r$, $z_r$) be the coordinates of a center of rotation $R$. Let $\psi$, $\theta$ and $\phi$ be rotations along axes parallel to the z-axis, y-axis and x-axis respectively. If I apply firstly a rotation $\psi$, then a rotation $\theta$ and lastly a rotation $\phi$ on the rigid body about point $R$, what will be the new coordinates of the point $P$?

Follow-up question

Let's say I have the coordinates of a large yet finite number of points defined on the surface of a rigid body stored in a 1D array in the following manner: [x1, y1, z1, ..., xn, yn, zn]. What is the most efficient algorithm to compute their new coordinates after a rotation as defined in the Main question?

Answer Thanks to mike I was pointed in the right direction. A pseudo-code to compute the rotation matrix as needed in his answer is the following:

function rotation_matrix_3d(psi, theta, phi)
    rotMat = [cos(theta)*cos(psi)                            -cos(theta)*sin(psi)                           sin(theta);
              cos(phi)*sin(psi)+sin(phi)*sin(theta)*cos(psi) cos(phi)*cos(psi)-sin(phi)*sin(theta)*sin(psi) -sin(phi)*cos(theta);
              sin(phi)*sin(psi)-cos(phi)*sin(theta)*cos(psi) sin(phi)*cos(psi)+cos(phi)*sin(theta)*sin(psi) cos(phi)*cos(theta)]

    return rotMat
share|cite|improve this question
up vote 1 down vote accepted

Let $\vec{v}_p=(x_p,y_p,z_p)$ and $\vec{v}_r=(x_r,y_r,z_r)$. Denote $\vec{v}_{p'}=(x_{p'},y_{p'},z_{p'})$ the coordinates of P after rotation.

Then we have: $$(\vec{v}_{p'}-\vec{v}_r)=R_x(\phi)R_y(\theta)R_z(\psi)(\vec{v}_{p}-\vec{v}_r)$$

So $$\vec{v}_{p'}=\vec{v}_r+R_x(\phi)R_y(\theta)R_z(\psi)(\vec{v}_{p}-\vec{v}_r)$$

share|cite|improve this answer
So you multiply the difference between the point and the rotation center by three rotation matrices. How does the compacted matrix look like? – cfbaptista Jun 22 '14 at 14:39
you may multiply them together. you may also refer to [1] – mike Jun 22 '14 at 15:10

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.