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

I was wondering how it would be possible for me to rotate a cube diagonally 360 degrees.

I am able to rotate it over the x-axis, y-axis and z-axis with the following formulas :


y = v.y*cos(degree) - v.z*sin(degree);
z = v.y*sin(degree) + v.z*cos(degree);


x = v.z * sin(degree) + v.x * cos(degree);
z = v.z * cos(degree) - v.x * sin(degree);


x = v.x * cos(degree) - v.y * sin(degree);
y = v.x * sin(degree) + v.y * cos(degree);

Thanks in advance!

share|cite|improve this question
You can look here for a visual aid :-) – robjohn Sep 15 '13 at 10:58
up vote 1 down vote accepted

Wikipedia will tell you everything:

share|cite|improve this answer

Given two vectors, $u$ and $v$, the cross-product with $u$ can be written in matrix form: $$ \begin{align} u\times v &=\begin{bmatrix}0&-u_3&u_2\\u_3&0&-u_1\\-u_2&u_1&0\end{bmatrix} \begin{bmatrix}v_1\\v_2\\v_3\end{bmatrix}\\[6pt] &=Y_uv\tag{1} \end{align} $$ Suppose $u$ is a unit vector. Then $u\times v$ is the orthogonal projection of $v$ onto the plane perpendicular to $u$ rotated $\pi/2$ (it is perpendicular to both $u$ and $v$).

The orthogonal projection of $v$ onto $u$ is given by $$ \begin{align} u(u\cdot v) &=\left(uu^T\right)v\\ &=Z_uv\tag{2} \end{align} $$

The orthogonal projection of $v$ onto the plane perpendicular to $u$ is given by subtracting the orthogonal projection of $v$ onto $u$ from $v$: $$ \begin{align} v-u(u\cdot v) &=\left(I-uu^T\right)v\\ &=X_uv\tag{3} \end{align} $$ Thus, rotating $v$ by angle $\theta$ around $u$ would be given by $$ \left(Z_u+\sin(\theta)Y_u+\cos(\theta)X_u\right)v\tag{4} $$ Since $X_u+Z_u=I$, the rotation matrix in $(4)$ can be rewritten as $$ I+\sin(\theta)Y_u-(1-\cos(\theta))X_u\tag{5} $$ where the matrices $X_u$ and $Y_u$ are given in $(3)$ and $(1)$ above.

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.