public class Point2D extends Object
Point2D
class defines a point representing a location
in (x,y)
coordinate space.
Modifier and Type | Field and Description |
---|---|
float |
x
The X coordinate of this
Point2D . |
float |
y
The Y coordinate of this
Point2D . |
Constructor and Description |
---|
Point2D()
Constructs and initializes a
Point2D with
coordinates (0, 0). |
Point2D(float x,
float y)
Constructs and initializes a
Point2D with
the specified coordinates. |
Modifier and Type | Method and Description |
---|---|
float |
distance(float px,
float py)
Returns the distance from this
Point2D to
a specified point. |
static float |
distance(float x1,
float y1,
float x2,
float y2)
Returns the distance between two points.
|
float |
distance(Point2D pt)
Returns the distance from this
Point2D to a
specified Point2D . |
float |
distanceSq(float px,
float py)
Returns the square of the distance from this
Point2D to a specified point. |
static float |
distanceSq(float x1,
float y1,
float x2,
float y2)
Returns the square of the distance between two points.
|
float |
distanceSq(Point2D pt)
Returns the square of the distance from this
Point2D to a specified Point2D . |
boolean |
equals(Object obj)
Determines whether or not two points are equal.
|
int |
hashCode()
Returns the hashcode for this
Point2D . |
void |
setLocation(float x,
float y)
Sets the location of this
Point2D to the
specified float coordinates. |
void |
setLocation(Point2D p)
Sets the location of this
Point2D to the same
coordinates as the specified Point2D object. |
String |
toString()
Returns a
String that represents the value
of this Point2D . |
public float x
Point2D
.public float y
Point2D
.public Point2D()
Point2D
with
coordinates (0, 0).public Point2D(float x, float y)
Point2D
with
the specified coordinates.x
- the X coordinate of the newly
constructed Point2D
y
- the Y coordinate of the newly
constructed Point2D
public void setLocation(float x, float y)
Point2D
to the
specified float
coordinates.x
- the new X coordinate of this Point2D
y
- the new Y coordinate of this Point2D
public void setLocation(Point2D p)
Point2D
to the same
coordinates as the specified Point2D
object.p
- the specified Point2D
to which to set
this Point2D
public static float distanceSq(float x1, float y1, float x2, float y2)
x1
- the X coordinate of the first specified pointy1
- the Y coordinate of the first specified pointx2
- the X coordinate of the second specified pointy2
- the Y coordinate of the second specified pointpublic static float distance(float x1, float y1, float x2, float y2)
x1
- the X coordinate of the first specified pointy1
- the Y coordinate of the first specified pointx2
- the X coordinate of the second specified pointy2
- the Y coordinate of the second specified pointpublic float distanceSq(float px, float py)
Point2D
to a specified point.px
- the X coordinate of the specified point to be measured
against this Point2D
py
- the Y coordinate of the specified point to be measured
against this Point2D
Point2D
and the specified point.public float distanceSq(Point2D pt)
Point2D
to a specified Point2D
.pt
- the specified point to be measured
against this Point2D
Point2D
to a specified Point2D
.public float distance(float px, float py)
Point2D
to
a specified point.px
- the X coordinate of the specified point to be measured
against this Point2D
py
- the Y coordinate of the specified point to be measured
against this Point2D
Point2D
and a specified point.public float distance(Point2D pt)
Point2D
to a
specified Point2D
.pt
- the specified point to be measured
against this Point2D
Point2D
and
the specified Point2D
.public int hashCode()
Point2D
.public boolean equals(Object obj)
Point2D
are equal if the values of their
x
and y
member fields, representing
their position in the coordinate space, are the same.Copyright © 2020. All rights reserved.