Jump to content
  • Advertisement
Sign in to follow this  
Nanook

Axis angle to Vector

This topic is 3143 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

I got an angle axis from a quoternion for an object in my game and need to find the direction vector for where the object is facing.. how can I find this?

Share this post


Link to post
Share on other sites
Advertisement
A quaternion represents a rotation about an axis angle, not an absolute direction. So, you can't find the direction the object is currently facing unless you know the original direction it faced.

If you know the original direction:
- create a 3x3 rotation matrix from the quaternion
- multiply the original direction of the object by the matrix

Share this post


Link to post
Share on other sites
Why would you go through the 3x3 matrix? Just take the original direction and rotate it using the quaternion normally (i.e., by conjugation).

Share this post


Link to post
Share on other sites
Im still not sure how to do this? When my game starts the original orientation would be the same as the current orientation wouldn't it?

Share this post


Link to post
Share on other sites
Quote:
When my game starts the original orientation would be the same as the current orientation wouldn't it?

Yes, before any changes are made. At that point, you should know which direction your object is facing. That's the direction you would use for the calc later.

Perhaps if you're a bit more specific about what language you're programming in, what the "object" is, etc., you can get more specific help.

Share this post


Link to post
Share on other sites
My problem is that I need to add an acceleration force to my spaceship so I need to know where its facing.. so I need to get the orientation vector so I can multiply that with my acceleration force.. Im using c++

I just started using quaternions so I need a good explenation..

I guess the original orientation is 0,0,-1 as I'm using opengl.. I've set it up so everytime a new orientation quaternion is set I multiply it by the previous orientation vector, but this doesn't seem to give me the right vector..

orientationDir is the vector (set to 0,0,-1 at startup) and orientation is the quaternion:

orientationDir = orientation * orientationDir;
orientationDir.normalize();

Share this post


Link to post
Share on other sites
I guess you just don't know how to apply to a vector a rotation specified by certain quaternion. You should probably read and understand the Wikipedia page about quaternions and rotation. Basicaly you need to multiply
rotated_vector = quaternion * original_vector * inverse(quaternion)

This operation is called "conjugation". Since the quaternion in question is a unit quaternion, you can compute its inverse just by flipping the sign of the three imaginary coefficients.

Share this post


Link to post
Share on other sites
Yeah I know I'm running out of time for this project right now though, but I will use time during my break to read on quaternions.. We're abit ahead with quaternions, we didn't realy need to use them.. so I just need to get this working now..

but does it matter what order I multiply them? Is this supposed to work?

orientationDir = orientation * orientation.inverse() * orientationDir;

Share this post


Link to post
Share on other sites
Quote:
everytime a new orientation quaternion is set I multiply it by the previous orientation vector

Is the "new" orientation quat the total orientation of the object, or a change in orientation?

If it's the total orientation, then don't multiply it by the previous orientation.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!