Archives Forums/Blitz3D Bug Reports/pitch/yaw/roll

b32(Posted 2007) [#1]
Finally I was able to isolate my problem. It is this:
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

pivot = CreatePivot()

RotateEntity pivot, 90, 90, 0

Print EntityPitch(pivot)
Print EntityYaw(pivot)
Print EntityRoll(pivot)

The yaw returns zero. So instead of returning 90,90,0 it returns 90,0,0.
Is this a bug ? Is there a way around this ? Thanks in advance.

markcw(Posted 2007) [#2]
I think this is called gimbal lock:

It is a known limitation when using Euler angles ie. it's not a bug. It happens when you try complex rotations. The known way around it is using quaterions. I've no idea how you do that though.

Stevie G(Posted 2007) [#3]
Definately Gimbal lock ... see this thread for possible solution.


b32(Posted 2007) [#4]
Aha, so this is the infamous Gimbal lock. Thanks a lot, I used fredborgs solution and it works now.
I also tried getting the pitch/yaw/roll directly from the GetMatElement() matrix, with the help of a routine from leadwerks. For completion, I added both functions:
Thanks again, after hunting me all night, I hope this Gimbal demon is exorcised for good now. :)

Because I needed the local angles too, I modified the FredBorg functions. As fas as I can tell they work, but I don't understand exactly how they work I just made them local (to the parent):