Re: Gravity Calculation-my way!

From: Aaron Howald <Ahowald_at_bilbo.w-link.net>
Date: Wed Nov 03 1999 - 06:38:18 EST

----- Original Message -----
From: Zonn <zonn@zonn.com>
To: <vectorlist@lists.cc.utexas.edu>
Sent: Tuesday, November 02, 1999 10:07 AM
Subject: Re: Gravity Calculation

> On Mon, 1 Nov 1999 22:30:17 -0700 , you wrote:
>
> >The look up table would have to be 131,072 bytes in size.
> >((256*256)+(256*256))
>
> Not using the shift lookup technique I described in an earlier message
> for the sqrt() function. Using the upper 8 bits as the index into the
> lookup table allows for a lookup table of 1272 bytes (assuming 1 byte
> results of the ^-1.5 function, the sqrt() always returned an answer
> that fit in one byte, this might not be true for the ^-1.5 function).
> Of course this limits your results to one of 1272 possible answers
> which is probably more than enough resolution.

I am using a 127x127 table-if two points are farther apart than 127 pixels ,
the number is shifted to fit in the table, the value is pulled from it, and
the result shifted back out, at a lesser resulution as the distance
increases.
(a quick and dirty abs(x)+abs(y) is done first to set the#of shifts)
This gives 1 pixel resulution out to 2x the maxium object size (in my game
vector engine) 2 pixel res out to 4x, 4 pix res out to 8x, etc...this is
mainly to be used for point to point collision detection...
Since the game screen is max 1024x1024, worse case error is 8 pixels off
(real pos vs. approximation) from screen corner to screen corner!
prehaps a bit memory hungry, but the speed is worth it...
Each object in my engine checks the last closet point on all other objects
(found by themselves before!!) to 3 points on itself-the closest last time,
and the 2 to either side. So say I have 20 objects (say, asteroids? :*)
flying around-each 'roid does 3 tests on all others-this is true for ALL of
them, so 3x19x19=1083 tests each FRAME! (19, since not testing itself...) I
need as much speed as i can get!
Also, I am proud to say this routine can do 3 things at once:
collision detection (by proximity or x/y crossing), gravity, and lighting!
The memory use IS worth it!
 BTW, I want to thank you all on all this discussion on gravity and distance
measurements-it has been quite helpful! I had no idea there were so many
ways to do it...
(I thought I'd throw in my $2 worth tonight!)

Aaron Howald
ahowald@w-link.net
Received on Wed Nov 3 04:39:22 1999

This archive was generated by hypermail 2.1.8 : Fri Aug 01 2003 - 00:32:27 EDT