This forum has been archived. All content is frozen. Please use KDE Discuss instead.

need to store position and orientation what should I use

Tags: None
(comma "," separated)
kollmanj
Registered Member
Posts
3
Karma
0
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 :)
Waxwing
Registered Member
Posts
10
Karma
0
OS
Doesn't answer your question, but here's how you could do it using a transformation matrix.

Code: Select all
Vector3d vl = Vector3d(4, 3, 0);

Quaterniond q = Quaterniond(AngleAxisd(M_PI / 2, Vector3d(0, 0, 1)));

Affine3d t = Affine3d(q);

Vector3d vg = t * vl;
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
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.
kollmanj
Registered Member
Posts
3
Karma
0
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
:)
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
v2 = quat * v1 + pos;
kollmanj
Registered Member
Posts
3
Karma
0
très bien

Marci hibou sage :)


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]