public class PointF
extends java.lang.Object
float coordinates.
This class is similar in spirit to Android's android.graphics.PointF and provides
basic point operations such as setting coordinates, negation, offsetting, equality checks,
and computing vector length.
| Modifier and Type | Field and Description |
|---|---|
float |
x
X coordinate.
|
float |
y
Y coordinate.
|
| Constructor and Description |
|---|
PointF()
Creates a point at the origin
(0, 0). |
PointF(float x,
float y)
Creates a point with the specified coordinates.
|
PointF(PointF p)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(float x,
float y)
Returns whether this point's coordinates are exactly equal to
(x, y). |
boolean |
equals(java.lang.Object o)
Indicates whether some other object is "equal to" this one.
|
int |
hashCode()
Returns a hash code value for this point.
|
float |
length()
Returns the Euclidean length of the vector from
(0,0) to this point: hypot(x, y). |
static float |
length(float x,
float y)
Returns the Euclidean length of the vector from
(0,0) to (x,y). |
void |
negate()
Negates this point in place:
(x, y) -> (-x, -y). |
void |
offset(float dx,
float dy)
Offsets this point in place by
(dx, dy): (x, y) -> (x + dx, y + dy). |
void |
set(float x,
float y)
Sets this point's coordinates.
|
void |
set(PointF p)
Sets this point's coordinates to match another point.
|
java.lang.String |
toString()
Returns a string representation of this point.
|
public PointF()
(0, 0).public PointF(float x,
float y)
x - x coordinatey - y coordinatepublic PointF(PointF p)
PointF with the same coordinates as p.p - the point to copy fromjava.lang.NullPointerException - if p is nullpublic final void set(float x,
float y)
x - new x coordinatey - new y coordinatepublic final void set(PointF p)
p - the source pointjava.lang.NullPointerException - if p is nullpublic final void negate()
(x, y) -> (-x, -y).public final void offset(float dx,
float dy)
(dx, dy): (x, y) -> (x + dx, y + dy).dx - delta xdy - delta ypublic final boolean equals(float x,
float y)
(x, y).
Note: this performs exact floating-point comparison using ==.
x - x coordinate to comparey - y coordinate to comparetrue if both coordinates match exactly; otherwise falsepublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the reference object with which to comparetrue if this object is the same as the o argument; otherwise falsepublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectPointF(x, y)public final float length()
(0,0) to this point: hypot(x, y).public static float length(float x,
float y)
(0,0) to (x,y).x - x componenty - y component