How much do I have to rotate an object around X, Y, Z in order to make it parallel to a line

99 Views Asked by At

I have a cone-shape 3D object like this:

cone 3D object

I have a line with a normalized direction vector like this:

Normalized vector = (-0.702755, -0.514791, -0.491045)

I want to rotate my cone so that it is parallel to my direction vector. So far I have tried this:

Cone rotation around X = Arccos(-0.702755)
Cone rotation around y = Arccos(-0.514791)
Cone rotation around z = Arccos(-0.491045)

But it is not rotating cone properly, I mean my cone is still not parallel to the direction vector/line. I wonder what is the best practice to do so. Thanks.

Update

Finally, the problem is resolved by the approach here:

https://stackoverflow.com/a/52465275/3405291

1

There are 1 best solutions below

2
On

Call the normalized vector $u'=(a',b',c')$ (it is messy to type long decimal numbers!) (So $a',b',c'$ are known specific constants) I assume you already have a specific cone with axis one some other line $u$ that you want rotated to $u'$?

Take the info about the current axis vector $u=(a,b,c)$. Here $a,b,c$ are also known (to you) specific constants, normalized.

Let $P$ and $P'$ be the planes for which $u$ and $u'$ are the normals.

SO they have equation $ax+by+cz=0, a'x+b'y+c'z=0$. Let $v,w$, and $v,'w'$ be vectors in $P$ and $P'$ forming orthornormal bases for $P$ and $P'$ respectively.

Now let $A, A'$ be the $3\times3$ matrices formed by these vectors as columns: $A=(u, v, w), \quad A'=(u',v',w')$.

Now the matrix $B= A'A^{-1}$ is the change-of-basis matrix needed. This matrix $B$ is known as you already have $(a,b,c)$ and $(a',b',c')$.

So for your cone satisfying equation $F(x,y,z)=0$ replace the vector $(x,y,z)$ by the $(x'y,z')=B\times (x,y,z)^T$. (here $\times$ means multiplying the square matrix by column vector) Now $F(x',y',z')=0$ is the equation of the cone you are looking for.