Public Group

# Quaternions, Whats the point

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

## Recommended Posts

I have created a simple FPS(First Person Shooter) style camera class. It contains up, right, position and look vectors and RotateX, RotateY, Strafe and Move functions. This class works perfectly and alows me to do all the stuff with the camera that any FPS style game can do. Now I hear all this talk of Euler Angles and Gimble lock and Quaternions been better. What advantages would Quaternions give me and what method am I using at the moment.

##### Share on other sites
I personally don't use quaternions in a view matrix, although I understand the pros of doing so.

The main thing I use quaternions for is to interpolate between matrices based on a certain time. (Mainly for a bone-joint animation system. )

##### Share on other sites
You don't allow the player to roll so they wouldn't offer you any capability advantage (you essentailly already have gimble lock and OK with it).

Quaternions are an alternative to using a vector and an angle to represent an arbitrary rotation. You can think of the difference between a Q and a VA as the difference between polar and rectangular cooridnates (except it's 3D, so it's spherical and cartesian).

They are a more sophisticated construct, but they ultimately make the math easier. Instead of having up, right, position, & look vectors (3float each * 5 = 15floats) and a rotate X and rotate Y (what are these for? 17 floats), you can represent the players orientation with one quaternion (4 floats) and do all you math on this one structure (with overloaded operators if you use C++). Vector+angle offers the same thing.

With your setup you have to worry about the up & right vectors becoming un-orthogonal due to float-point error aggreagation (if you do lots of math on them over & over, the inprecision of floating-point number adds up and soon the vectors aren't orthogonal nor have a length of 1.) A quaterion can become denormalized as well (will no longer have a magnitude of 1), but you won't have to fudge it back into a corner.

• 18
• 20
• 12
• 21
• 16