Registered Member
|
I'm a noob, and I want to use eigen instead of the math library I made for my little project:
www.enlightenengineering.com I have rigid body class which stores a position in 3d (x,y,z) and orientation. I now use a 3d vector and a quaternion (this is with my own classes). In moving to eigen I want to know what would be best. I have to transform vectors from local to global and visa versa all the time so I would like to store the most efficient representation of orientation to accomplish these transformations. Also, I often calculate a quaternion which I want to pass in as the orientation for the body. Should I use Transform or Quaternion and Vector3d for position. If I do use quaternion, how do I use it to change a vector from local to global ( quaternion math looks like this: vg = q * vl * q* ) vg: vector global vl: vector local q: quaternion q*: conjugate of quaternion q Thanks |
Registered Member
|
Doesn't answer your question, but here's how you could do it using a transformation matrix.
|
Moderator
|
that also depends on:
1 - whether you have to store many such Isometries => a Quaternion is more compact, 2 - whether you want to interpolate between them (e.g., keyframe animation) => Quaternion, 3 - whether you transform many vectors by the same rotation => Transform To give you some idea, here are the cost to transform n vectors: Quaternion: 30n Matrix3: 24 + 15n Moreover, if you add a translation, then the transformation of one or many vectors by a Affine3* or Isometry3* is vectorized. So except you fit in the case 1 and/or case 2, I'd go for one of the Transform<> incarnations. |
Registered Member
|
Thanks for the replies.
But, I still do not know how to use a quaternion to convert a vector from local to global coordinates. What is the method or combination of methods that does the 30n operations required to transform n vectors? Thanks |
Moderator
|
v2 = quat * v1 + pos;
|
Registered Member
|
très bien
Marci hibou sage |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]