[ODE] vector to matrix math

Jon Watte (ODE) hplus-ode at mindcontrol.org
Mon Aug 22 09:58:08 MST 2005


There are an infinite number of matrices that do that, because the 
vector you have does not have an "up" only a "forward". So any matrix 
that rotates the unit vector to match your vector would do, and then you 
can get arbitrary roll around that vector.

Typically, when finding "what takes vector A and rotates it to vector B" 
you will take A cross B, and normalize it; that's your axis of rotation; 
then acos( A dot B ) is your angle of rotation. You can find this method 
in the Matrix and Quaternion FAQ, by the way!

Cheers,

			/ h+


Pawel S wrote:
> Hello everyone!
> 
> I have a mathematical problem not related to ODE.
> 
> I need to find out the 3x3 matrix that represents the orientation of a
> vector. This vector is the direction of a thrust vector from a thruster.
> The matrix is needed in order to correctly represent the exhaust flame
> graphically.
> 
> For exemple the direction down = cVector( 0.0, -1.0, 0.0 ) could be
> represented by the matrix:
> 
>   1.0, 0.0, 0.0
> [ 0.0, 1.0, 0.0 ] = the identity matrix
>   0.0, 0.0, 1.0
> 
> and the direction cVector( 1.0, 0.0, 0.0 ) could be represented by the
> matrix:
> 
>    0.0, 1.0, 0.0
> [ -1.0, 0.0, 0.0 ]
>    0.0, 0.0, 1.0
> 
> I appreciate any help.
> 
> Pawel S
> 
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
> 
> 


More information about the ODE mailing list