Trying a partial post... hopefully I can put it up in pieces... |
* This software is made available under the RoboWiki Public Code License (RWPCL). The full text of * the license may be found at http://robowiki.net/cgi-bin/robowiki?RWPCL. |
* This software is made available under the RoboWiki Limited Public Code License (RWLPCL). The full * text of the license may be found at http://robowiki.net/cgi-bin/robowiki?RWLPCL. |
import robocode.Rules; |
... |
/** * Adds the X and Y components of the given Point2D.Double objects and returns a new * Point2D.Double object with the result. */ public static Point2D.Double add(Point2D.Double point1, Point2D.Double point2) { return new Point2D.Double(point1.x + point2.x, point1.y + point2.y); } /** * Subtracts the X and Y components of the second given Point2D.Double object from those of the * first and returns a new Point2D.Double object with the result. */ public static Point2D.Double subtract(Point2D.Double point1, Point2D.Double point2) { return new Point2D.Double(point1.x - point2.x, point1.y - point2.y); } /** * Returns the absolute bearing in radians from the given origin point to the given target * point. */ public static double getAbsoluteTargetBearing?(Point2D.Double origin, Point2D.Double target) { return Utils.normalAbsoluteAngle?(Math.atan2(target.x - origin.x, target.y - origin.y)); } /** * Returns a Point2D.Double object indicating the relative position of an object at the given * angle and distance from the origin. */ public static Point2D.Double getRelativePosition?(double angle, double distance) { double dx = distance * Math.sin(angle); double dy = distance * Math.cos(angle); return new Point2D.Double(dx, dy); } /** * Returns a Point2D.Double object indicating the position of an object at the given angle and * distance from the given origin point. */ public static Point2D.Double getAbsolutePosition?(Point2D.Double origin, double angle, double distance) { double x = origin.x + distance * Math.sin(angle); double y = origin.y + distance * Math.cos(angle); return new Point2D.Double(x, y); } /** * Converts degrees to radians. */ public static double degToRad?(double degrees) { return degrees * Math.PI / 180; } /** * Converts radians to degrees. */ public static double radToDeg?(double radians) { return radians * 180 / Math.PI; } } |