calculating quaternions

This topic is 4916 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

How do I calculate the quaternion if I only have the up/y coordinate for each local axis rotated into world coordinate. I assume this leaves one DOF which is a rotation about world Y axis, the value for this can be arbitrary. thanks

Share on other sites
I'm not quite sure from your wording, but tell me if this is what you mean. You have an orthonormal basis:

x.x, x.y, x.z
y.x, y.y, y.z
z.x, z.y, z.z

You only know x.y, y.y, and z.y, and you want to extract a quaternion (or more generally an orientation) from this information.

I think I have an answer, but first I'm curious as to whether I understood your question correctly. Also, I'm wondering what you need this for, as there may be other, better solutions.

[Edited by - jyk on August 2, 2005 3:07:19 PM]

Share on other sites
You understood it correctly.

I have asked this questions before but I don't think I got a satisfactory answer.

The reason that I only have the y coordinates for each axis, is that the data is from a set of motion capture datas and I wish to learn some sort of statistical model and I don't want the learning to be sensitive to the root orientation, except for its "uppness". However I still want to be able get a sensible/consistent orientation from just the y coordinates.

It would be even better if I can use it in conjunction with another orientation (a propery one) and some how combine their characteristics.

I am open to suggestions of alternative representations.

thanks

Share on other sites
Quote:
 You understood it correctly.I have asked this questions before but I don't think I got a satisfactory answer.The reason that I only have the y coordinates for each axis, is that the data is from a set of motion capture datas and I wish to learn some sort of statistical model and I don't want the learning to be sensitive to the root orientation, except for its "uppness". However I still want to be able get a sensible/consistent orientation from just the y coordinates.It would be even better if I can use it in conjunction with another orientation (a propery one) and some how combine their characteristics.I am open to suggestions of alternative representations.
Yes, I think I remember this (from some months ago).

I don't understand the statistical modelling aspect well enough to help with that, but I can comment on just the math part. If the problem really is just building an orientation around a set of basis vector y coordinates, that at least can be solved.

Consider that if the rows of a 3x3 matrix form an orthonormal basis, then so do the columns (and vice versa). So, you could consider the vector (x.y, y.y, z.y) to be one of the vectors in an orthonormal basis, and then find (x.x, y.x, z.x) and (x.z, y.z, z.z) in the usual way (ask if you're not sure what I'm talking about). Then you'll have a full orientation matrix, and can extract a quaternion from there if needed.

Geometrically, the set of orientations with common y components would be, I think, all possible rotations of a single orthonormal basis about the y axis. The above procedure would return one of these, but which would be arbitrary.

I wish I understood your overall goal well enough to be more helpful, but maybe the above suggestion will be of some use to you.

Share on other sites
Quote:
 Original post by jykConsider that if the rows of a 3x3 matrix form an orthonormal basis, then so do the columns (and vice versa). So, you could consider the vector (x.y, y.y, z.y) to be one of the vectors in an orthonormal basis, and then find (x.x, y.x, z.x) and (x.z, y.z, z.z) in the usual way (ask if you're not sure what I'm talking about). Then you'll have a full orientation matrix, and can extract a quaternion from there if needed.

If you could explain more in detail that would be great. I remember it being something about cross products but I forget the exact details.

My overall goal is to construct an inverse kinematic system that can optimise for a pose with root orientation that has the same or similar (x.y, y.y, z.y) as some other poses. However optimising for root orientation and root position, is more difficult than I initially thought.

Share on other sites
Quote:
 If you could explain more in detail that would be great. I remember it being something about cross products but I forget the exact details.
The IK stuff sounds pretty complicated, but I can at least answer this question. The steps would be something like this:

1. Construct the vector (x.y, y.y, z.y). This is your first basis vector.
2. Cross this vector with an arbitrary vector to get the second basis vector.
3. Normalize the second basis vector.
4. Cross the first two to get the third basis vector.

Steps 2 and 4 need a little clarification. When I say an arbitrary vector, I mean any vector not aligned with the first. A common approach is to cross with the world axis corresponding to the component of the basis vector with the least absolute value.

Another concern is that you might end up with a (mathematically) left-handed system with determinant -1. An easy solution is to check for this and negate the first or third basis vector if necessary.

Once you have your solution, remember to transpose it to get the actual orientation, since you started out with x.y, y.y, z.y.

I'm not sure how clear that was, so I'll try to sketch out some pseudocode:

Vector3 y(xy, yy, zy);
Vector3 x;
if (/*y.x has least absolute value*/) x = y.Cross(1, 0, 0);
else if (/*y.y has least absolute value*/) x = y.Cross(0, 1, 0);
else if (/*y.z has least absolute value*/) x = y.Cross(0, 0, 1);
x.Normalize();
z = x.Cross(y);
if (x.Dot(y.Cross(z)) < 0) z = -z;
Matrix3x3 result;

Share on other sites
Thanks very much, I give that a try.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 9
• 15
• 14
• Forum Statistics

• Total Topics
634070
• Total Posts
3015332
×