VECTORLIST - The Mailing List For The Technical Discussion of Vector-Based Arcade Games

November_1999
RE: Gravity Calculation


From: jeff hendrix ( )
Date: Mon Nov 01 1999 - 16:25:13 CST


This seems to work, but how do I implement ^-1.5 in assembly?

-jeff

-----Original Message-----
There is a faster way...

Compute: D = ((xLen * xLen) + (yLen * yLen)) ^ -1.5
          dx = xLen * D
          dy = yLen * D
          speed.x += dx
          speed.y += dy

The -1.5 exponent seems strange, but you'll note that there is no need
to compute the unit vector this way. Whatever iterative method you use
for square root may apply to this as well. I presented this to the Xpilot
team several years back, and they got a good speed boost from it - that
game can have a LOT of gravity sources.

BTW, the "obvious" way to extend to 3D works, as that is where it came
from (take the gradient of the gravitational potential field (-1/r) in
cartesian coordinates). Hope it helps.

--
 ___   __   _   _  _
|   \ /  \ | | | || |             Engineer/Programmer
|  _/| || || |_| || |__     " What makes someone care so much?
|_|  |_||_| \___/ |____)      for things another man can just ignore. "
-S.H.


HOME