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'm in $R^3$ and I have a solid 3d object and a vector, I would like to rotate and orient the solid according to this vector.

I found that the simplest way to do that is to use euler angles, the problem with this solution is that computing the final rotation matrix requires time and the process is too much "verbose": I'm wondering, there is a quicker way to rotate this solid according to a vector ?

EDIT: This is what I want in a nutshell



share|cite|improve this question
What does it mean to rotate and orient something "according to" a vector? – Rahul Aug 24 '13 at 18:46
@RahulNarain see my edit – user1154 Aug 24 '13 at 19:17
So, you want to rotate the cone so that its axis becomes parallel to the given vector. Is that correct? – bubba Aug 25 '13 at 4:29
up vote 1 down vote accepted

I assume that the rotation will be done by multiplying row vectors on the right by the matrix. In other words, the rotation function will be $(x', y' z') = (x,y,z)\cdot\mathbf R$, where $\mathbf R$ is the rotation matrix.

Let $\mathbf u = (a,b,c)$ be a unit vector in the desired direction. For $\mathbf R$, we simply have to use a rotation matrix that has $(a,b,c)$ as its third row. Then it is easy to check that $(0,0,1) \cdot \mathbf R = (a,b,c)$, so the $z$-axis gets rotated as desired.

The first two rows of $\mathbf R$ can be anything you like, as long as the matrix is orthogonal.

One common approach is to let $\mathbf v$ be some other unit vector orthogonal to $\mathbf u$, and let the rows of $\mathbf R$ be $\mathbf v$, $\mathbf v \times \mathbf u$, and $\mathbf u$.

If your convention is to use column vectors and to pre-multiply by the rotation matrix, then just transpose everything -- the vector $(a,b,c)$ should become the third column of the rotation matrix, instead.

share|cite|improve this answer

What I used to do was to use a basis formed by this vector (unitary, and any other two orthonormal vectors, so you can express the rotation matrix by:

$$R=\pmatrix{1&0&0\\ 0&\sin\alpha&\cos\alpha\\ 0&-\cos\alpha&\sin\alpha}$$

Now, just do tha change of basis to that matrix by multiplying by the matrix formed of the vector you previously chose.

I doubt though this is quicker than anything, although it's a solution. Just be carefull ith the multiplication:

$$R'=PR$$ $R'$ being the matrix of the rotation in your initial basis, and $P$ being the matrix that has the columns of the vectors chosen for the rotation, the first column must be the axis (normalized), and the other two can be any couple of orthonormal vector, also orthogonal to the first one.

share|cite|improve this answer
mmm, basically It's still better to stick with Euler – user1154 Aug 24 '13 at 19:18

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.