What's the math behind DELTAYAW?

Blitz3D Forums/Blitz3D Programming/What's the math behind DELTAYAW?

FlagDKT(Posted 2008) [#1]
I need to reproduce DELTAYAW function.
What's the math behind it?


Floyd(Posted 2008) [#2]
Here's a note I made to myself long ago.

; What is DeltaYaw?

; There are two entities, a source and a destination ( target ).
; Imagine the center ( origin ) of the target projected onto the X-Z plane.
; i.e. ignore the y-coordinate. Do the same with the Z+ axis of the source.

; Think of this projected axis as a vector ( arrow ) in the X-Z plane.
; How much must it be turned to point at the target? The answer is DeltaYaw( source, target )

; This should always give the angle through which source must be turned about
; the vertical ( global Y ) axis.


Function Delta_Yaw#( src, dest )  ;  Simulate DeltaYaw

	dx# = EntityX(dest,True) - EntityX(src,True)
	dz# = EntityZ(dest,True) - EntityZ(src,True)
	
	angle# = ATan2( -dx, dz ) - EntityYaw(src,True)
	
	If angle <= -180 Then angle = angle + 360
	If angle >  +180 Then angle = angle - 360
	 
	Return angle

End Function



FlagDKT(Posted 2008) [#3]
Thank you :)