1
$\begingroup$

enter image description here

I need to rotate a vector using transformation matrix. For example: I heave vector Z (0, 0, 1). I'm rotating it by 100 deg around Z-Axis. Result will be the same as input. How to compute the angle which vector was rotated around own axis?
I think I need more support vectors (like I painted on pic above). Of course I'm not rotatig around 3 main axes. Rotation can be any in 3D.

$\endgroup$

1 Answer 1

1
$\begingroup$

Check out this Wikipedia article on the rotation of vectors in $\mathbb{R}^3$. It describes the transformation matrix used for the rotation of a vector about an arbitrary unit vector by an arbitrary angle.

Regarding the computation of the rotation angle, we consider the rotation of an arbitrary vector $\vec{A}$ about some unit vector (the rotation axis) by an angle of $\theta$ to get $\vec{B}$. The dot product of the two gives $\vec{A}\cdot\vec{B} = |\vec{A}||\vec{B}|\cos{\theta}$, or more explicitly,

$$\cos{\theta} = \frac{\vec{A}\cdot\vec{B}}{|\vec{A}||\vec{B}|}$$ This allows you to compute the rotation angle ($\theta$) from the vectors before and after rotation.

As for the computation of the rotation axis, we simply take and normalize the cross product of $\vec{A}$ with $\vec{B}$. I hope you can see why.

$\endgroup$
7
  • $\begingroup$ I'm rotating using matrix. When I rotate a vector using matrix, I will get new coordinates. But I will not get angle (which that vector was rotated around itself - itself means around axis which this vector now describes). $\endgroup$
    – apocalypse
    Feb 3, 2014 at 12:20
  • $\begingroup$ I've edit my answer to make more explicit the restoration of the rotation angle from the vectors before and after a rotation transform. Do check it out! $\endgroup$
    – Yiyuan Lee
    Feb 3, 2014 at 12:50
  • $\begingroup$ I have input vector A. I have rotation matrix which produce output vector B. To insert "physical component" in some 3D app, I need to give an postion, a direction (that produced vector B) and the angle. Everything I havem but not angle :( I must use these 2 inputs (vector A and matrix) to obtain pos, dir and angle :/ $\endgroup$
    – apocalypse
    Feb 3, 2014 at 12:50
  • $\begingroup$ I believe you want to write something which allows the user to interact with your model and to rotate it about? $\endgroup$
    – Yiyuan Lee
    Feb 3, 2014 at 12:52
  • $\begingroup$ If you have the input vector $\vec{A}$, and the rotation matrix $\textbf{R}$, you could simply compute the output vector $\vec{B}$ by multiplying $\vec{A}$ with $\textbf{R}$, and use the dot product approach mentioned in the amended answer. $\endgroup$
    – Yiyuan Lee
    Feb 3, 2014 at 12:56

You must log in to answer this question.

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