Error in EntityPitch!!!!

BlitzMax Forums/MiniB3D Module/Error in EntityPitch!!!!

KimoTech(Posted 2007) [#1]
Hi all .. I discovered when i needed the global pitch of an rotating entity, it always just goes to 90 or -90 degrees, and it turns back again.. 0....90....0....-90....0 and so on. Shouldn't it go from 0....180....0....-180....0 like EntityYaw and EntityRoll??


DJWoodgate(Posted 2007) [#2]
No, that is correct. You can think of pitch and yaw as latitude and longitude. Any point on the earth can be specified by the north to south latitude having a range of 180 degrees and east to west longitude having a range of 360 degrees. So any direction in 3d can be specified by pitch ranging from -90 to 90 and yaw from -180 to 180.


KimoTech(Posted 2007) [#3]
But can anyone then tell me: If i turn a cube 1 degree for each frame on the pitch axis, then when i recieve the global rotations from EntityPitch, Yaw, Roll, then the pitch only goes from -90 to 90, and Yaw switches from 0 to 90 each time EntityPitch reaches 90 or -90, and the same by Roll, it just switches between 0 and -180? But i only rotate around the pitch axis.

Try this test:
...
Repeat
TurnEntity cube, 1, 0, 0
Text 0,0,EntityPitch(cube,true)
Text 0,20,EntityYaw(cube,true)
Text 0,40,EntityRoll(cube,true)
Text 0,60,EntityPitch(cube,false)
Text 0,80,EntityYaw(cube,false)
Text 0,100,EntityRoll(cube,false)
RenderWorld
Flip
Forever

.. then you will see, that the global and local coords are extremely different, even than the cube doesnt have a parent?


DJWoodgate(Posted 2007) [#4]
Well IMO it shouldn't do that. It does not do it in Blitz3d.

Without digging into it too much I would guess it is to do with Turnentity. It does say in the readme that it does not work in the same way. I think you will need to use quaternions as suggested to get around it.


Oddball(Posted 2007) [#5]
It's the informous Gimbal lock and is a product of using euler rotations. As many different values of Yaw, Pitch and Roll can reprisent exactly the same angle, miniB3D has to chose one combination and stick to it or you'd get lots of varying results for identical orientations. Further reading for those who are interested in learning more.


KimoTech(Posted 2007) [#6]
no because if you do so:

Repeat
RotateEntity cube, EntityPitch(cube,true) + 1, EntityYaw(cube,true) + 1, EntityRoll(cube,true) + 1, true
Text 0,0,EntityPitch(cube,true)
Text 0,20,EntityYaw(cube,true)
Text 0,40,EntityRoll(cube,true)
Text 0,60,EntityPitch(cube,false)
Text 0,80,EntityYaw(cube,false)
Text 0,100,EntityRoll(cube,false)
RenderWorld
Flip
Forever


... then the cube doesnt spin around, but in some strange ways?