Targeting function
Dar Scott
dsc at swcp.com
Sun Jun 29 12:26:00 EDT 2003
On Sunday, June 29, 2003, at 05:02 AM, curry wrote:
> The input could be gun location, bullet speed, target location, target
> direction, and target speed. The output could be bullet direction or
> collision point.
Here is an alternate approach that doesn't take all that preliminary
math and has no trig.
At the collision point the ratio of the distances to the original
target location and the gun location should the the same as the ration
of their speeds.
Step out along the path of the target several times and see if you find
a point in which the ratio is within some tolerance of the speed ratio.
If there is one, the enemy has a place to shoot at.
The distance between two points is the square root of the sum of the
delta x and the delta y. Since this is approximate (I assume misses
are OK sometimes) then, rather than calculating the square root over
and over, you can just square the speed rations and compare to that,
maybe, I think, YMMD.
Dar Scott
More information about the use-livecode
mailing list