[futurebasic] Re: [FB] Physics-Speed

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2000 : Group Archive : Group : All Groups

From: Phil Yates <phil.yates@...>
Date: Sat, 16 Dec 2000 23:16:43 +0000
on 15/12/00 9:14 pm, Peter Dempsey at theviron@... wrote:

>> If you look at my Radar program on Staz's site somewhere I think you'll see
>> that it has everything you want. It works in Angles 0 - 360 in 0.5 degree
>> steps, and contains functions to work out most everything you need. All the
>> Trig is pre-calculated for speed, and sits in two arrays. If you want them,
>> let me know direct and I'll pull them out. Just say if you want FB2 or FB3.

> Like how much faster is it with everything precalculated and then stored?
> My game has only whole number angles, so it would be very easy to get a
> variable that stores the info about that angle.  If it shaved some time then
> that would definitely be worth it. Also, how big would 720 variables be? (x
> & y movement for 360 degrees)

Work it out for yourself. To obtain the X & Y Increments for each aircraft
you just need to call :

gAcxIncr!(Ac) = (gAcSpd(Ac) * gCosData#(gAcHdg(Ac))) / (60 * _Udr)
gAcyIncr!(Ac) = (gAcSpd(Ac) * gSinData#(gAcHdg(Ac))) / (60 * _Udr)

(Udr is the update rate - how often you update the aircraft in seconds)

If you don't precalculate, you have to a) convert the Aircraft Heading in
degrees to Radians, then b) apply Cos and Sin to the resultant figure. A
lookup table will always be faster.

Phil.