quaternions

BlitzMax Forums/OpenGL Module/quaternions

Drey(Posted 2006) [#1]
what are these exactly and what are they used for?


simonh(Posted 2006) [#2]
Check out Chris C's tutorial:

http://www.blitzbasic.com/Community/posts.php?topic=55697


Drey(Posted 2006) [#3]
So it's for rotation..i'm assuming it's faster than using OpenGL rotate X,Y,Z. It's for making rotation it seems and i don't understand what this math does that a system that makes X,Y,Z rotation to another set of X,Y,Z using addition or multiplication can't.


simonh(Posted 2006) [#4]
It's just another way of spceifying rotations. Euler angles (pitch, yaw, roll), are fine for most purposes but when you want you want to interpolate between angles (such as for animation), it's usually better to use quaternions as Euler angles can suffer from 'gimbal lock'.

Blitz3D uses quaternions internally but hides it from the user.


Chris C(Posted 2006) [#5]
Interestingly you can still demonstrate gimbal lock with Blitz3d as it reduces things back to eular angles...

For most applications running round on a surface you'll never experience problems with the dreaded gimbal lock, so its really kind of a mute point

The main reason for using quats is for smooth translations of facing
if you are making a flight sim or elite type space shooter, then you need to ensure all your rotations are done in quats to ensure you avoid gimal lock


Drey(Posted 2006) [#6]
gimbal lock? so you basically you apply pitch, yaws, roll into this matrix system..do some calcs and it returns new p,y,r?


Chris C(Posted 2006) [#7]
huh?


Drey(Posted 2006) [#8]
I'm asking what is gimbal lock? Is that when you hit the 90 degree angles on the pitch and it acts a fool? So quarternions defines angles in matrix formatted matter that elimates the arc trig problems with returning angles from slopes and such?

What exactly does the W define in quarternions and does matrix math generially run faster when it's in the language or when OpenGL does calcs?


Chris C(Posted 2006) [#9]
Gimbal lock occurs when 2 rotational axes become aligned

W is the quats scalar, bare in mind that a quat is 4d...

all calculations should be done with quats and at the last stage converted to a matrix as this is what is needed by opengl...


Drey(Posted 2006) [#10]
when does that happen? and what's the 4th dimension.


Chris C(Posted 2006) [#11]
quite literally the 4th is imaginary!

you usually convert to a matrix in order to set up opengl to draw an object in a quats orientation, so immediatly before drawing a 3d shape


Drey(Posted 2006) [#12]
alright, well. I've been studying on my own and i think i found the site you got your source from Chris. But i'm still a bit confused. All I want to do is just put in 3 Eular Angles, get the get the proper X,Y,Z,W values, do the instant rotation multiplation and be done. I don't care about converting from a rotation matrix and such( which seems to be more easy to find and understand that what i'm asking for right now). Can someone help with that.


Chris C(Posted 2006) [#13]
I certainly used more than one resource to create that tutorial and the code!!
The code also contains historical code from my own software library, if you look at the code you will see a number of functions you can directly call to achieve exactly what you're after


Drey(Posted 2006) [#14]
Ok, this is what confuses me. When you're gettin a quat from a Angle and then Pitch, Yaw, Roll. I don't understand what Angle parameter? Do i just put 0 or 1 because Pitch, Yaw, and Roll have already been discribe. Also, with the Pitch, Yaw, Roll..are those in angles anyhow? Seems like they are vectors. I know how to convert them to vectors using spherical units.


Drey(Posted 2006) [#15]
OK, got it.