[Gambas-user] angle interpolation algorithm troubles
Kevin Fishburne
kevinfishburne at ...1887...
Fri Feb 17 07:52:12 CET 2012
On 02/17/2012 01:11 AM, Randall Morgan wrote:
> Try a little conditional:
>
> if abs(a1 - a2)> 180 then rotate counter clockwise
> else rotate clockwise
>
> I think this will work try it and see...
Thou art a genius. :) I used your suggestion along with this site:
http://www.kirupa.com/forum/showthread.php?63633-shortest-distance-between-two-angles
and came up with:
' Check if camera orientation is locked to client player orientation.
If Camera.Locked Then
' Move camera orientation closer to player orientation (interpolate).
Distance = Convert.Wrap_Single(0, 359, Abs(Camera.Orientation -
Client.Player[Client.Number].Orientation))
If Distance > 180 Then Distance = 360 - Distance
If Abs(Convert.Wrap_Single(0, 359, Camera.Orientation -
Client.Player[Client.Number].Orientation)) > 180 Then
Camera.Orientation = Convert.Wrap_Single(0, 359, Camera.Orientation
+ 0.1 * Distance)
Else
Camera.Orientation = Convert.Wrap_Single(0, 359, Camera.Orientation
- 0.1 * Distance)
Endif
Endif
It works brilliantly. Muchas gracias and domo arigato.
--
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271
More information about the User
mailing list