Quaternions Test

Blitz3D Forums/Blitz3D Programming/Quaternions Test

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Ok??? I think, the mistake is in the QUA_EulerToQuat function...

I replaced with

Function QUA_EulerToQuat2(Pitch#, Yaw#, Roll#)
	
	Pitch# = Pitch# / 2.0
	Yaw#   = Yaw#   / 2.0
	Roll#  = Roll#  / 2.0
	
	Cos_Pitch# = Cos(Pitch#)
	Cos_Yaw#   = Cos(Yaw#)
	Cos_Roll#  = Cos(Roll#);
	
	Sin_Pitch# = Sin(Pitch#)
	Sin_Yaw#   = Sin(Yaw#)
	Sin_Roll#  = Sin(Roll#);
	
	CpCy# = Cos_Pitch# * Cos_Yaw#
	SpSy# = Sin_Pitch# * Sin_Yaw#
	SpCy# = Sin_Pitch# * Cos_Yaw#
	CpSy# = Cos_Pitch# * Sin_Yaw#

	q.QUA_Quat=Last QUA_Quat
	If q=Null q=New QUA_Quat

	q\z = ((Sin_Roll# * CpCy#) - (Cos_Roll# * SpSy#))*-1
	q\x = ((Cos_Roll# * SpCy#) + (Sin_Roll# * CpSy#))*-1
	q\y = (Cos_Roll# * CpSy#) - (Sin_Roll# * SpCy#)
	q\w = (Cos_Roll# * CpCy#) + (Sin_Roll# * SpSy#)

End Function

and it seems to walk right

... Of course, it does not explain why 3 codes for getting Euler from Quat return 3 different values