Package lejos.robotics.geometry
Class Point2D
- java.lang.Object
-
- lejos.robotics.geometry.Point2D
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
Point2D.Double,Point2D.Float
public abstract class Point2D extends java.lang.Object implements java.lang.CloneableAn abstract class for a point. Subclasses implement float, double and integer coordinates.- Author:
- Lawrie Griffiths
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPoint2D.DoubleA point with double coordinates.static classPoint2D.FloatA point with float coordinates.
-
Constructor Summary
Constructors Modifier Constructor Description protectedPoint2D()This is abstract class that cannot be instantiated.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()doubledistance(double px, double py)Get the distance from this point to a given point as a doublestatic doubledistance(double x1, double y1, double x2, double y2)Get the the distance between two pointsdoubledistance(Point2D pt)Get the distance from this point to a given point asa doubledoubledistanceSq(double px, double py)Get the square of the distance between two pointsstatic doubledistanceSq(double x1, double y1, double x2, double y2)Get the square of the distance between two pointsdoubledistanceSq(Point2D pt)Get the square of the distance of this point to a given pointbooleanequals(java.lang.Object obj)Test if this point is equal to a given objectabstract doublegetX()Get the x coordinate as a doubleabstract doublegetY()Get the y coordinate as a doubleabstract voidsetLocation(double x, double y)Set the location of this Point2D using double coordinatesvoidsetLocation(Point2D p)Set the location of this Point2D to the same as a specified Point2D
-
-
-
Method Detail
-
getX
public abstract double getX()
Get the x coordinate as a double- Returns:
- the x co-ordinate (as a double)
-
getY
public abstract double getY()
Get the y coordinate as a double- Returns:
- the y coordinate (as a double)
-
setLocation
public abstract void setLocation(double x, double y)Set the location of this Point2D using double coordinates- Parameters:
x- the new x coordinatey- the new y coordinate
-
setLocation
public void setLocation(Point2D p)
Set the location of this Point2D to the same as a specified Point2D- Parameters:
p- the specified Point2D
-
distanceSq
public static double distanceSq(double x1, double y1, double x2, double y2)Get the square of the distance between two points- Parameters:
x1- the x coordinate of the first pointy1- the y coordinate of the first pointx2- the x coordinate of the second pointy2- the y coordinate of the second point- Returns:
- the square of the distance between the points as a double
-
distance
public static double distance(double x1, double y1, double x2, double y2)Get the the distance between two points- Parameters:
x1- the x coordinate of the first pointy1- the y coordinate of the first pointx2- the x coordinate of the second pointy2- the y coordinate of the second point- Returns:
- the distance between the points as a double
-
distanceSq
public double distanceSq(double px, double py)Get the square of the distance between two points- Parameters:
px- the first pointpy- the second point- Returns:
- the square of the distance between the points as a double
-
distanceSq
public double distanceSq(Point2D pt)
Get the square of the distance of this point to a given point- Parameters:
pt- the given point- Returns:
- the square of the distance to the given point as a double
-
distance
public double distance(double px, double py)Get the distance from this point to a given point as a double- Parameters:
px- the x coordinate of the given pointpy- the y coordinate of the given point- Returns:
- the distance to the given point as a double
-
distance
public double distance(Point2D pt)
Get the distance from this point to a given point asa double- Parameters:
pt- the given point- Returns:
- the distance to the given point as a double
-
equals
public boolean equals(java.lang.Object obj)
Test if this point is equal to a given object- Overrides:
equalsin classjava.lang.Object
-
clone
public java.lang.Object clone()
- Overrides:
clonein classjava.lang.Object
-
-