Jump to content
  • Advertisement
Sign in to follow this  
My_Mind_Is_Going

Quaternions or not?

This topic is 3985 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'm working on a small FPS game/demo that I'm planning to use as part of a portfolio for job applications. I have my viewing system implemented currently using just Euler angles and regular rotation matrices and it's working fine (no Gimbal lock or anything) so far. I've been thinking though because Quaternions are a pretty standard part of computer graphics it might look better if I replaced my current system with a Quaternion system. I've never had a need for them before but I suppose it's considered a standard tool in the industry to know how to work with them so I should probably do it for my own education. Does anyone have any interesting perspective on this?

Share this post


Link to post
Share on other sites
Advertisement
Spreadsheets are a standard tool in the industry too. Should you add a spreadsheet to your FPS?

Using a technology where it is not necessary will not give you a good education about it.

Share this post


Link to post
Share on other sites
Quaternions would be useful if the player could fly around in any direction since there's no good way to use euler angles in such an environment. When the player is stuck with their feet pointing towards the ground and can look up and down, yaw and pitch angles make more sense. Yaw and pitch don't make sense in an environment with no distinct up or down, since the effects of changing the yaw vary depending on the current pitch (when looking straight up, you seem to roll when you turn).

Maybe add a flying anti-gravity drone enemy that uses quaternions to do complex maneuvers. Scripted maneuvers could just as well be implemented as a series of euler angles...quaternions do allow smoother blending between different orientations though.

Share this post


Link to post
Share on other sites
Quaternions really shine when interpolation becomes involved. If you have a pair of transformations stored as matrices, you can't interpolate between the two easily (and maybe not at all?). With quaternions, you can blend two transforms directly and cheaply. And if you don't care about perfect results, you can do it really cheaply (lerp components and renormalize iirc).

Share this post


Link to post
Share on other sites
Just wanted to echo what has been hinted at before: the thing that will probably impress potential employers most is if you use the right tool for the job at hand (Euler angles and matrices in the case of an FPS character). So I wouldn't recommend using quaternions just because you think it's expected or necessary.

You could use quaternions for something else though (as suggested). For example, quaternions would be a reasonable choice for representing the orientation of a guided missile in flight.

I'll also mention that matrices and quaternions are more or less interchangeable as far as rotations go. Each has various practical advantages and disadvantages with respect to the other, but with respect to rotations, their fundamental behavior is the same. (For what it's worth, you can even apply spherical linear interpolation - slerp - to rotation matrices, although it's not as efficient or elegant as with quaternions.)

Share this post


Link to post
Share on other sites
Quote:
Original post by Promit
If you have a pair of transformations stored as matrices, you can't interpolate between the two easily (and maybe not at all?).

You can interpolate matrices, if you interpolate two 3x3 rotation matrices and two equivalent quaternions the resultant orientations will also be equivalent, the diference is that the interpolation was cheaper with a quaternion.

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!