Jump to content

  • Log In with Google      Sign In   
  • Create Account


Quaternion questions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 AblazeSpace   Members   -  Reputation: 161

Like
Likes
Like

Posted 06 July 2001 - 09:28 PM

How could I transform a direction vector to a quaternion? How could I get out the x/y/z rotation from a quaternion? How could I create a smooth interpolation between two quaternion? (slow at beginning, fastest at middle and slow at the end) Questions over questions... I hope someone could help me.

Sponsor:

#2 johnb   Members   -  Reputation: 347

Like
Likes
Like

Posted 08 July 2001 - 10:57 PM


> How could I transform a direction vector to a quaternion?

If you mean to a rotation quaternion you can''t. A direction vector does not specify a rotation. You need more information, such as where the vector is rotated from and how the rotation takes place.

> How could I get out the x/y/z rotation from a quaternion?

There''s standard code to extract Euler angles from a rotation quaternion, see Gamedev''s articles section.

> How could I create a smooth interpolation between two
> quaternion? (slow at beginning, fastest at middle and slow
> at the end)

Use slerp with a ''smoothing'' function. E.g. if your usual slerp function is

result = slerp (q0, q1, t)

with t ranging from 0 to 1, instead use

result = slerp (q0, q1, 0.5 - 0.5 * cos(s))

where s ranges from 0 to pi. The function

t = 0.5 - 0.5 * cos(s)

is an example of a function that smooths out the motion: look at the graph of cos to see why. There are a wide range of functions that do this, or only smooth the beginning or ending.

#3 AblazeSpace   Members   -  Reputation: 161

Like
Likes
Like

Posted 09 July 2001 - 01:29 AM

Thanks for your answer!!

>> If you mean to a rotation quaternion you can''t. A direction vector does not specify a rotation. You need more information, such as where the vector is rotated from and how the rotation takes place.

- Do you have any code for doing this??

#4 johnb   Members   -  Reputation: 347

Like
Likes
Like

Posted 09 July 2001 - 04:17 AM

> - Do you have any code for doing this??

No. The problem is you''re problem is not precise enough, you need more information. The code depends on what extra information you have. E.g. if you have the axis about which the rotation takes place you might find the angle you must turn through, giving you the angle-axis description of the rotation, which is then easy to convert to a quaternion. But it depends on what info you have.

#5 AblazeSpace   Members   -  Reputation: 161

Like
Likes
Like

Posted 09 July 2001 - 06:07 AM

Are there other good tutorials than the on Gamedev, Gamasutra??

#6 David20321   Members   -  Reputation: 122

Like
Likes
Like

Posted 09 July 2001 - 09:07 AM

>>There''s standard code to extract Euler angles from a rotation
>>quaternion, see Gamedev''s articles section.

I''ve been looking for a way to do this for a long time, if you had a specific link to the article it would be great because I can''t find it

Oh yeah and for the direction vector maybe you could find the euler angles for it and convert that to a quaternion.

-David-



#7 johnb   Members   -  Reputation: 347

Like
Likes
Like

Posted 09 July 2001 - 09:03 PM

>>There''s standard code to extract Euler angles from a rotation
>>quaternion, see Gamedev''s articles section.

> I''ve been looking for a way to do this for a long time, if you
> had a specific link to the article it would be great because I
> can''t find it

Sorry, the article I was thinking of (the Gamasutra one) dosen''t have quaternion -> Euler angle conversion. It has conversion the other way, and converting to and from matrices.

The reason is there''s no need for it: the only use for Euler angles is for inputting or initialising a rotation, inside game code both quaternions or matrices are easier, quicker and more accurate to use. I''ve not yet found a problem that requires Euler angles at any stage of a calculation.


#8 Void   Members   -  Reputation: 126

Like
Likes
Like

Posted 09 July 2001 - 10:35 PM

You will be able to retrieve euler from a quat if you can retrieve euler from a matrix.

However, retrieveing euler angles from matrix is not easy, if possible, as euler to matrix is a many-to-one relationship.

#9 David20321   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 July 2001 - 06:09 AM

I just wanted euler cause I can easily apply it to a vector, how do I apply a quaternion to a vector? I have a game with a spaceship that rotates around using quaternions but it can''t go forward because I can''t figure out what the rotated vector is. Any help would be great.
Thanks,
-David-

#10 AblazeSpace   Members   -  Reputation: 161

Like
Likes
Like

Posted 10 July 2001 - 06:51 AM

David20321: I will send you my math functions.

#11 David20321   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 July 2001 - 06:08 PM

Thanks a lot! Problem solved!

-David-




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS