[ODE] some math questions

Roel van Dijk roelvandijk at home.nl
Wed Jul 2 10:10:02 2003


On Tuesday 01 July 2003 22:13, Fig TaTam wrote:
> I also want to know if there is a function for transforming a vector by a
> quaternion

I don't think there is a function to directly transform a vector by a
quaternion. You could first convert the quaternion to a rotation matrix and
then multiply the vector by that matrix.

Little example:
// Some body
dBodyID body;

// A quaternion
dQuaternion q;
q = dBodyGetQuaternion (body);

// A rotation matrix
dMatrix3 m;

// Convert the quaternion to a 4x3 rotation matrix
dQtoR (q, m);

// A vector
dVector3 v = {0.0, 1.0, 0.0}; // put some values in the vector

// The rotated vector
dVector rv;

// Multiply the vector with the matrix
dMULTIPLY1_331 (rv, m, v);

// end of example

You can also write your one functions to do these things.

Roel