At the moment if you rotate a 3D object like so :
// EXAMPLE 1
x_movement x,y,z
x_rotation rotx, 1, 0, 0
x_rotation roty, 0, 1, 0
x_rotation rotz, 0, 0, 1
x_drawobj cube, 0
We suffer from gimbal lock (is that the correct term)? - For example you can't set the object to point upwards and rotate on the Y axis and keep rotating on the X axis perfectly while manipuating y or z rotations, BUT if we do something like :
// EXAMPLE 2
x_movement x, y, z
x_rotation rotx, 1, 0, 0
x_pushmatrix
x_rotation roty, 0, 1, 0
x_rotation rotz, 0, 0, 0
x_drawobj cube, 0
x_pushmatrix
We can achieve the desired rotation of our object. We can then use x_getmatrix after the x_drawobj to get the coordinates of said object.
My question is this : How do I get the real angles rotx, roty, rotz from example 2 so I can draw other objects using the method in example 1? I can't base the other objects inside the original push / pop matrix as they also get changed when the original object changes rotation, I need to be able to grab the x, y, z & the rotation angles for reuse.
I'm not sure if there are other bits from the output of x_getmatrix that I can use? I've looked but the don't seem to make much sense on how to use them apart from mat[12] / 13 & 14 which are the objects x,y,z.
Bit of a messy question but I think it makes sense? :)
um, ignore the above post, it's a load of messed up junk, lol :noggin:
The only way to get rid of gimbal lock is to re-write all the rotation routines to use quaternions. I've no idea what they are and how they work (yet) :D but they will solve the problem with GLBasics eular angles and good old gimbal lock.
Right, where did I leave my reading glasses, six pack of beer and thinking cap? :S
Hmm that's odd. I just did a search for "Quaternion" and got no results, and yet I'm positive someone (maybe Hemlos) was working on such a thing.
Edit: Egads... 5 minutes reading Wikipedia entries on Gimbal Lock, Euler Angles and Quaternion's and my head is spinning from all this math-ey stuff!
Quote from: Ocean on 2011-Nov-06
Quote from: Hatonastick on 2011-Nov-06
.... I just did a search for "Quaternion" and got no results, .....
Have you checked this board http://www.glbasic.com/forum/index.php?board=29.0 ?
It's even sticky!
Ocean
Gah! Ok... As the females in my family put it: "I did a male look."