# History of CircularTargeting

Robo Home | Changes | Preferences | AllPages

Revision 49 . . (edit) January 15, 2009 21:00 EST by Dummy
Revision 48 . . July 26, 2008 0:39 EST by c122-108-56-1.sunsh1.vic.optusnet.com.au [Time estimate for delooped circular targeting]
Revision 47 . . (edit) April 8, 2008 21:28 EST by Starrynte [starting deloop...]

Difference (from prior major revision) (minor diff, author diff)

Changed: 36,37c36,37
 ( 5 ) newX(T) = relativeX + http://kcl.kwokkie.net/klli87/images/sum.gif enemyVelocity*sin(initialHeading + t*turnrate) ( 6 ) newY(T) = relativeY + http://kcl.kwokkie.net/klli87/images/sum.gif enemyVelocity*cos(initialHeading + t*turnrate)
 ( 5 ) newX(T) = relativeX + http://kcl.kwokkie.net/klli87/images/_sum.gif enemyVelocity*sin(initialHeading + t*turnrate) ( 6 ) newY(T) = relativeY + http://kcl.kwokkie.net/klli87/images/_sum.gif enemyVelocity*cos(initialHeading + t*turnrate)

Changed: 43,44c43,44
 ( 7 ) newX(T) = relativeX + enemyVelocity * http://kcl.kwokkie.net/klli87/images/integral.gif sin(initialHeading + t*turnrate) dt ( 8 ) newY(T) = relativeY + enemyVelocity * http://kcl.kwokkie.net/klli87/images/integral.gif cos(initialHeading + t*turnrate) dt
 ( 7 ) newX(T) = relativeX + enemyVelocity * http://kcl.kwokkie.net/klli87/images/_integral.gif sin(initialHeading + t*turnrate) dt ( 8 ) newY(T) = relativeY + enemyVelocity * http://kcl.kwokkie.net/klli87/images/_integral.gif cos(initialHeading + t*turnrate) dt

 --- The loop is only necessary to work out the time `t` when the bullet will hit the robot. If you can guess `t` beforehand, you can avoid the looping and just shoot at where the enemy will be at time `t`. A working estimate for `t` is the time it takes to shoot a bullet into the centre of the enemy's movement: double t = Math.sqrt(Math.pow(getX() - movementCentreX?, 2) + Math.pow(getY() - movementCentreY?, 2))/bulletSpeed; Plug this into equations (9) and (10) above and you have co-ordinates to shoot at. This might not give you the smallest possible value of `t` for a given bullet speed (I haven't checked, but the code seems to do rather poorly against sample.Corners), but it'll give you a value that works. The only way I know to get a smaller value of `t` will require iteration as you're essentially backing out roots from a trig function. Of course, it goes without saying that a delooped circular targeting gun will be useless against anything that doesn't move in great arcs. If you want to hit those robots, you're better off sticking with the iterative method. But since a delooped circular targeting gun runs in constant time, it can form part of a virtual guns system without causing you to skip turns on massive battlefields. --duyn