fun rotation math that i just cant get right

BlitzMax Modules Forums/MiniB3D/fun rotation math that i just cant get right

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.

Here's modified faceeach.
I just change the Atan with your pre-point way to get target rotation.
A mod operation can help you limit the angle within 360.
Happy coding. :-)
Function faceeach(f1:face, f2:face)
	Local ca:Float = EntityYaw(f1.Entity(), True)
	PointEntity(f1.Entity(), f2.Entity())
	Local ta:Float = EntityYaw(f1.Entity(), True)
	
	Local la:Float = 45
	Local da:Float = ta - ca
	Local dif:Float = Abs(da) - la
	
	If dif > 0 Then
		Local da1:Float = Cos(da + la)
		Local da2:Float = Cos(da - la)
		If da1 >= da2 Then
			'use +360 mod 360 to limit angle within 0-360
			RotateEntity(f1.Entity(), 0, (ta + la + 360) Mod 360, 0, True)
		Else
			RotateEntity(f1.Entity(), 0, (ta - la + 360) Mod 360, 0, True)
		End If
	Else
		RotateEntity(f1.Entity(), 0, ca, 0, True) 'restore current angle
	EndIf
End Function