# Talk:Circular Targeting

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

## General discussion

Does anyone have a good way to put the iterative predicitive stuff (ala the NCLP) into an ExtendsRobot bot? --Alphax

FOR loops --UnderDark

Thank you, Captain Obvious.

The problem is that it's useful to have scans on consecutive ticks for that. You could either stop your bot and try and get two consecutive scans, or if the other bot is really moving in a roughly even curve, you can find the change in heading and divide it by the number of ticks between observations.

Of course, you should probably just use an AdvancedRobot, or not do circular targeting - if you're trying to enter it into a competition where only ExtendsRobot is allowed, none of your opponents will be moving in curves. -- Kawigi

`double TurnRate = (Math.abs(Heading1-Heading2))/(Math.abs(TimeOfHeading1-TimeOfHeading2));`

Hope this helps --UnderDark

Here is a play on Circular Targeting, it uses math only, its the Orbit gun from my nanobot Orbit (expanded of course, which wasn't an easy task). This piece of code could maybe be changed into a circle gun by putting something into the aimAngle calculation. (and calculating where that center is).

Orbit's Gun

```double absoluteBearing = e.getBearingRadians() + getHeadingRadians();
double bulletSpeed = (20 - 3 * bulletPower);
double distance = e.getDistance();
double circularTravel = absoluteBearing + lateralVelocity / bulletSpeed;
double aimAngle = Math.atan2(distance * Math.sin(circularTravel), distance * Math.cos(circularTravel));