[Gambas-user] angle interpolation algorithm troubles

Randall Morgan rmorgan62 at ...626...
Fri Feb 17 08:23:02 CET 2012


My Game programming days go back to DOS and WinG and the last thing I
worked on was using DirectX 6 and it was brand new then. Much has changed
since then. Even C and C++ and the coding styles used now are completely
different. So I am glad this old man could help!




On Thu, Feb 16, 2012 at 10:52 PM, Kevin Fishburne <
kevinfishburne at ...1887...> wrote:

> 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
>
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
If you ask me if it can be done. The answer is YES, it can always be done.
The correct questions however are... What will it cost, and how long will
it take?



More information about the User mailing list