[Home]History of PluggableRobot/Math2

Robo Home | Changes | Preferences | AllPages


Revision 5 . . (edit) November 2, 2007 23:52 EST by RobertWalker [Oops, wrong class]
Revision 4 . . (edit) November 2, 2007 23:51 EST by RobertWalker [Loosened the license]
Revision 3 . . (edit) September 22, 2007 2:47 EST by RobertWalker
Revision 1 . . September 22, 2007 2:46 EST by RobertWalker
  

Difference (from prior major revision) (minor diff)

Removed: 1d0
Trying a partial post... hopefully I can put it up in pieces...

Changed: 6,7c5,6
* 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.

Removed: 14d12
import robocode.Rules;

Changed: 51c49,106
...
/**
* 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;
}
}

Robo Home | Changes | Preferences | AllPages
Search: