AlignToVector

BlitzMax Modules Forums/MiniB3D/AlignToVector

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.

When the 'rate' parameter was added to AlignToVector I was curious about what it really meant.
Some experimenting suggested it was doing this:

1. The axis to be aligned and the target vector determine a plane.
2. The entity turns about an axis perpendicular to this plane.
3. The rate gives the fraction of the "angle difference" to turn.

This last part means that a rate of 0.5 will turn half the way to the target.
Graphics3D 500, 400, 0, 2
SetBuffer FrontBuffer()

piv = CreatePivot() : TurnEntity piv, 0, 160, 0

For n = 1 To 5
	Print EntityYaw( piv )
	AlignToVector piv, 0, 0, 1,    3, 0.5   ; turn half the way to the target
Next

WaitKey : End

One possible glitch arises if the original axis and the target vector point in exactly opposite directions. In that case they do not determine a plane and the problem become ill-defined. Try changing 160 to 180 in the example.