Oh wow, this is gonna sound really retarded, but, couldn't you do something like this? Its probably bigger, but I dislike loops. package chase.nano; import static java.lang.Math.*; import robocode.*; public class NanoCircle extends AdvancedRobot { public static double lastX, lastY, lastHeading; public void run() { lastX = lastY = 0; while(true) { setTurnRadarRightRadians(Double.POSITIVE_INFINITY); } } public void onScannedRobot(ScannedRobotEvent e) { double absAngle, x, y, heading; absAngle = e.getBearingRadians() + getHeadingRadians(); x = getX() + sin(absAngle) * e.getDistance(); y = getY() + cos(absAngle) * e.getDistance(); heading = e.getHeadingRadians(); if(lastX != 0) { //the lines, unmutilated //b=-tan(heading + PI/2)*x+y //lastB=-tan(lastHeading + PI/2)*lastX+lastY double m1,m2,b1,r, circleX;; double circleY = (circleX = ((m2=-tan(heading + PI/2))*x+y - (b1=(m1=-tan(lastHeading + PI/2))*lastX+lastY)) / (m1 - m2))*m1+b1; //the radius, fyi r = sqrt((circleX-x)*(circleX-x)+(circleY-y)*(circleY-y)); //yay, I found the center, now to project along it //.. I kinda got lost here, but I would think find //where the bullet can intercept the robot } lastX = x; lastY = y; lastHeading = heading; setTurnRadarLeftRadians(getRadarTurnRemainingRadians()); } }
--Chase-san
|