Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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 :

**x-axis**

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

**y-axis**

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

**z-axis**

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

Thanks in advance!

share|improve this question
1  
You can look here for a visual aid :-) –  robjohn Sep 15 '13 at 10:58
add comment

2 Answers 2

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|improve this answer
add comment

Your Answer

 
discard

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.