Jump to content
  • Advertisement
Sign in to follow this  
Kande

Retrieving a directional Vector from a quaternion and back.

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i need to know how to get a directional vector that spots in the same direction than a quaternion does. I dont know if this is possible but a quaternion doesnt do anything else, it shows a direction or orientation. The way back i also think thats its not really possible. But if i have a directional normalized vector that spots into a direction, it should be possible to construct a quaternion out of...... or not? Thanks in advance Kande

Share this post


Link to post
Share on other sites
Advertisement
If I understand what you are asking, to get a new facing vector after a quaternion has been applied simply transform the origianl facing vector by the quaternion. To get a quaternion from an original facing vector and a new facing vector, use a shortest arc equation to get the rotation quaternion.

Share this post


Link to post
Share on other sites
No, not really. I dont want to create a new vector out of an old one, using the quaternion. A quaternion is showing a orientation in space and so does a facing vector. For example: Vector(1,0,0) is facing down the X-Axis. Now i want to calculate the quaternion, that is also facing down the X-Axis.

The other way around i want to be able to get the Vector(1,0,0) again with an operation on the quaternion.

Share this post


Link to post
Share on other sites
Quaternions are rotations, that's it. A quaternion does not denote a facing vector except in context with an original facing vector. There is no such thing as a quaternion that faces down the X-axis.

Share this post


Link to post
Share on other sites
OK, quaternions are rotations. Then i must be able to get the quaternion from a vector A that was rotated to a vector B. For example A(1,0,0) and B(0,1,0) what is a 90 degrees rotation. Is that possible?

Share this post


Link to post
Share on other sites
Quote:
Original post by Kande
OK, quaternions are rotations. Then i must be able to get the quaternion from a vector A that was rotated to a vector B. For example A(1,0,0) and B(0,1,0) what is a 90 degrees rotation. Is that possible?

yes and no. you cant get THE quaternion that does this, but you can get the one quaternion that does this through the shortest path. cross those two vectors to find the axis to rotate about. use the dotproduct (look up its definition) to find the angle between them. then convert this axis-angle pair to a quaternion, in a manner google is most willing to provide you.

Share this post


Link to post
Share on other sites
Quote:
A quaternion is showing a orientation in space and so does a facing vector.
You're right that a quaternion can be interpreted as an orientation in 3-space, but a facing vector does not describe an orientation. More specifically, it does not uniquely describe an orientation, but rather corresponds to a subset of all possible orientations. So there is no direct way to convert between a single direction vector and a quaternion.

Perhaps what you are looking for is quaternion->matrix conversion. The resulting matrix contains three basis vectors that describe a coordinate frame; these vectors can be interpreted as side, up, and forward.

Share this post


Link to post
Share on other sites
You can compute a unique quaternion that describe a frame; a rotation frame is usually defined by a forward and an up vector.
In this case you can use a matrix3x3 or a quaternion; both describe the unique rotation that transform the identity frame in your current frame.
A quaternion itself has no special meaning.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!