http://www.blitzbasic.com/codearcs/codearcs.php?code=490
shows how to take a typical quat and convert to blitz euler.
I would prefer this to be done in C++ for speed of course!
Another thing - ODE has a function to convert quat to euler - why isn't this used?
Perhaps this can be converted to C++ and included in the lib?
shows how to take a typical quat and convert to blitz euler.
I would prefer this to be done in C++ for speed of course!
Another thing - ODE has a function to convert quat to euler - why isn't this used?
; convert a Quat to a Rotation Function QuatToEuler(out.Rotation, src.Quat) Local sint#, cost#, sinv#, cosv#, sinf#, cosf# Local cost_temp# sint = (2 * src\w * src\y) - (2 * src\x * src\z) cost_temp = 1.0 - (sint * sint) If Abs(cost_temp) > QuatToEulerAccuracy cost = Sqr(cost_temp) Else cost = 0 EndIf If Abs(cost) > QuatToEulerAccuracy sinv = ((2 * src\y * src\z) + (2 * src\w * src\x)) / cost cosv = (1 - (2 * src\x * src\x) - (2 * src\y * src\y)) / cost sinf = ((2 * src\x * src\y) + (2 * src\w * src\z)) / cost cosf = (1 - (2 * src\y * src\y) - (2 * src\z * src\z)) / cost Else sinv = (2 * src\w * src\x) - (2 * src\y * src\z) cosv = 1 - (2 * src\x * src\x) - (2 * src\z * src\z) sinf = 0 cosf = 1 EndIf ; Generate the output rotation out\roll = -ATan2(sinv, cosv) ; inverted due to change in handedness of coordinate system out\pitch = ATan2(sint, cost) out\yaw = ATan2(sinf, cosf) End Function
Perhaps this can be converted to C++ and included in the lib?