public class Point extends Object implements Serializable
The Point
used by JBotSim.
The third dimension is optional. When not provided, it is implicitly set to zero.
Constructor and Description |
---|
Point()
Creates a
Point object. |
Point(double x,
double y)
Creates a
Point object with the provided coordinates. |
Point(double x,
double y,
double z)
Creates a
Point object with the provided coordinates. |
Point(Point p)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
double |
distance(double x,
double y)
Computes the distance between the current point and the point represented by the provided coordinates.
|
double |
distance(double x,
double y,
double z)
Computes the distance between the current point and the point represented by the provided coordinates.
|
static double |
distance(double x1,
double y1,
double x2,
double y2)
Computes the distance between two points.
|
double |
distance(Point pt)
Computes the distance between the current point and provided one.
|
boolean |
equals(Object obj) |
double |
getX()
Gets the current abscissa.
|
double |
getY()
Gets the current ordinate.
|
double |
getZ()
Gets the current applicate.
|
int |
hashCode() |
void |
setLocation(double x,
double y)
Changes the current coordinates to those the provided ones.
|
protected void |
setLocation(double x,
double y,
double z)
Changes the current coordinates to those the provided ones.
|
void |
setLocation(Point p)
Changes the current coordinates to those of the provided
Point . |
String |
toString() |
public Point()
Creates a Point
object.
The coordinates correspond to the origin of the system.
public Point(double x, double y)
Creates a Point
object with the provided coordinates.
x
- the abscissa, as a double.y
- the ordinate, as a double.public Point(double x, double y, double z)
Creates a Point
object with the provided coordinates.
x
- the abscissa, as a double.y
- the ordinate, as a double.z
- the applicate, as a double.public static double distance(double x1, double y1, double x2, double y2)
Computes the distance between two points.
x1
- abscissa of the first point, as a double.y1
- ordinate of the first point, as a double.x2
- abscissa of the second point, as a double.y2
- ordinate of the second point, as a double.public double distance(double x, double y, double z)
Computes the distance between the current point and the point represented by the provided coordinates.
x
- the abscissa, as a double.y
- the ordinate, as a double.z
- the applicate, as a double.public double getZ()
Gets the current applicate.
public double getX()
Gets the current abscissa.
public double getY()
Gets the current ordinate.
public void setLocation(Point p)
Changes the current coordinates to those of the provided Point
.
p
- the Point
to copy coordinates from.public void setLocation(double x, double y)
Changes the current coordinates to those the provided ones.
x
- the new abscissa, as a double.y
- the new ordinate, as a double.protected void setLocation(double x, double y, double z)
Changes the current coordinates to those the provided ones.
x
- the new abscissa, as a double.y
- the new ordinate, as a double.z
- the new applicate, as a double.public double distance(double x, double y)
Computes the distance between the current point and the point represented by the provided coordinates.
x
- the abscissa, as a double.y
- the ordinate, as a double.public double distance(Point pt)
Computes the distance between the current point and provided one.
pt
- the other Point
.