Re: Trig and the infamous "45 degree angle bug"
>I remember this one... and I recall that my last suggestion didn't
>work (once you went full speed in one direction, you couldn't turn),
>so let me try something else.
>
>speed = sqrt((xv*xv)+(yv*yv))
>if speed > maxspeed then
> xv = xv * maxspeed / speed
> yv = yv * maxspeed / speed
>end if
>
>Basically the normalizing the vector idea, only it's scaled to
>maxspeed instead of 1. This should preserve the angle that the ship is
>trying to go, but without converting it from rectangular to polar and
>back again.
It works! 100% perfect. Well, at least to printf()'s default 8 decimal
precision places.. :)
_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]
|
Not Categorized, Please Help
|
|