java.lang.Object
com.marginallyclever.donatello.Point2D
public class Point2D
extends java.lang.Object
Represents a cartesian coordinate in 2D, with double precision.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description doubledistance(Point2D p)Returns the distance to some otherPoint2D.doubledistanceSquared(Point2D p)Returns the square of the distance to some otherPoint2D.doublelength()Returns the distance to the origin.doublelengthSquared()Returns the square of the distance to the origin.voidscale(double scale)Scales this point about the origin.voidset(double x0, double y0)Sets this to some cartesian (x0,y0) value.voidset(Point2D p)Sets this to some otherPoint2D.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
x
public double xthe cartesian coordinates. -
y
public double ythe cartesian coordinates.
-
-
Constructor Details
-
Method Details
-
set
public void set(double x0, double y0)Sets this to some cartesian (x0,y0) value.- Parameters:
x0- the new x value.y0- the new y value.
-
set
Sets this to some otherPoint2D.- Parameters:
p- the otherPoint2D.
-
lengthSquared
public double lengthSquared()Returns the square of the distance to the origin.- Returns:
- the square of the distance to the origin.
-
length
public double length()Returns the distance to the origin.- Returns:
- the distance to the origin.
-
scale
public void scale(double scale)Scales this point about the origin.- Parameters:
scale- the amount to scale
-
distanceSquared
Returns the square of the distance to some otherPoint2D. -
distance
Returns the distance to some otherPoint2D.
-