|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.geom.Point2D
java.awt.geom.Point2D.Double
math.geom2d.Point2D
public class Point2D
A point in the plane defined by its 2 cartesian coordinates x and y. The class provides static methods to compute distance between two points.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.awt.geom.Point2D |
|---|
java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Float |
| Field Summary | |
|---|---|
static Point2D |
INFINITY_POINT
The point located at the infinity. |
| Fields inherited from class java.awt.geom.Point2D.Double |
|---|
x, y |
| Fields inherited from interface math.geom2d.Shape2D |
|---|
ACCURACY, defaultClipWindow, EMPTY_SET |
| Constructor Summary | |
|---|---|
Point2D()
construct a new Point2D at position (0,0). |
|
Point2D(double x,
double y)
constructor with given position. |
|
Point2D(java.awt.geom.Point2D point)
Constructor from a java awt.geom Point2D, included for compatibility. |
|
Point2D(java.awt.geom.Point2D point1,
double x,
double y)
Constructor from a java awt.geom Point2D, and two double. |
|
Point2D(java.awt.geom.Point2D point1,
java.awt.geom.Point2D point2)
Constructor from two java awt.geom Point2D, summing their coordinates. |
|
| Method Summary | |
|---|---|
static Point2D |
centroid(java.util.Collection<? extends Point2D> points)
Computes the centroid, or center of mass, of a collection of points. |
static Point2D |
centroid(java.awt.geom.Point2D[] points)
Computes the centroid, or center of mass, of an array of points. |
static Point2D |
centroid(java.awt.geom.Point2D pt1,
java.awt.geom.Point2D pt2,
java.awt.geom.Point2D pt3)
Compute the centroid of three points. |
Shape2D |
clip(Box2D box)
Returns either the point itself, or the shape EMPTY_SET, depending on whether the point lies inside the specified box. |
boolean |
contains(double x,
double y)
return true if the two points are equal. |
boolean |
contains(double x,
double y,
double w,
double h)
Always return false. |
boolean |
contains(java.awt.geom.Point2D p)
return true if the two points are equal. |
boolean |
contains(java.awt.geom.Rectangle2D r)
Always return false. |
static Point2D |
createPolar(double rho,
double theta)
create a new point from polar coordinates rho and
theta. |
static Point2D |
createPolar(double x0,
double y0,
double rho,
double theta)
create a new point from polar coordinates rho and
theta, from the position (x0,y0). |
static Point2D |
createPolar(Point2D point,
double rho,
double theta)
create a new point from polar coordinates rho and
theta, from the given point. |
static double |
cross(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
Deprecated. |
static double |
dot(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
Deprecated. |
boolean |
equals(java.lang.Object obj)
Two points are consided equal if their euclidean distance is less than Shape2D.ACCURACY. |
java.awt.geom.Point2D.Double |
getAsDouble()
Convert point to an double version. |
java.awt.geom.Point2D.Float |
getAsFloat()
Convert point to a float version. |
java.awt.Point |
getAsInt()
Convert point to an integer version. |
Box2D |
getBoundingBox()
Returns the bounding box of the shape. |
java.awt.Rectangle |
getBounds()
Return bounding box of the shape. |
java.awt.geom.Rectangle2D |
getBounds2D()
Return more precise bounds for the shape. |
Shape2D |
getClippedShape(Box2D box)
Returns either the point itself, or the shape EMPTY_SET, depending on whether the point lies inside the specified box. |
double |
getDistance(double x,
double y)
Compute the distance between current point and point with coordinate (x,y). |
static double |
getDistance(double x1,
double y1,
double x2,
double y2)
|
double |
getDistance(java.awt.geom.Point2D point)
Compute the distance between this and the point point. |
static double |
getDistance(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
|
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform t)
Return null |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform t,
double flatness)
return a circle enclosing the point, which radius is the specified flatness. |
Shape2D |
getTransformedShape(AffineTransform2D trans)
|
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if the Point2D intersects the interior of a specified rectangular area. |
boolean |
intersects(java.awt.geom.Rectangle2D r)
Tests if the Point2D intersects the interior of a specified rectangle2D. |
boolean |
isBounded()
Returns true if the point is bounded. |
static boolean |
isColinear(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2,
java.awt.geom.Point2D p3)
test if the three points are colinear. |
static Point2D |
midPoint(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
|
Point2D |
minus(java.awt.geom.Point2D p)
|
Point2D |
plus(java.awt.geom.Point2D p)
|
void |
setPolarLocation(double rho,
double theta)
Set location specified as polar coordinate : distance from origin + angle with horizontal. |
void |
setPolarLocation(java.awt.geom.Point2D point,
double rho,
double theta)
Set location at distance 'rho' from given point, and making an angle 'theta' with horizontal. |
Point2D |
transform(AffineTransform2D trans)
transform the shape by an affine transform. |
| Methods inherited from class java.awt.geom.Point2D.Double |
|---|
getX, getY, setLocation, toString |
| Methods inherited from class java.awt.geom.Point2D |
|---|
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, hashCode, setLocation |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Point2D INFINITY_POINT
| Constructor Detail |
|---|
public Point2D()
public Point2D(double x,
double y)
public Point2D(java.awt.geom.Point2D point)
public Point2D(java.awt.geom.Point2D point1,
java.awt.geom.Point2D point2)
public Point2D(java.awt.geom.Point2D point1,
double x,
double y)
| Method Detail |
|---|
public static final Point2D createPolar(double rho,
double theta)
rho and
theta.
public static final Point2D createPolar(Point2D point,
double rho,
double theta)
rho and
theta, from the given point.
public static final Point2D createPolar(double x0,
double y0,
double rho,
double theta)
rho and
theta, from the position (x0,y0).
@Deprecated
public static final double dot(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
x1*y2 + x2*y1
Dot product is zero if the vectors defined by the 2 points are orthogonal. It is positive if vectors are in the same direction, and negative if they are in opposite direction.
@Deprecated
public static final double cross(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
x1*y2 - x2*y1
cross product is zero for colinear vector. It is positive if angle between vector 1 and vector 2 is comprised between 0 and PI, and negative otherwise.
public static final double getDistance(double x1,
double y1,
double x2,
double y2)
public static final double getDistance(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
public static final boolean isColinear(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2,
java.awt.geom.Point2D p3)
public static final Point2D midPoint(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
public static final Point2D centroid(java.awt.geom.Point2D[] points)
points - an array of points
public static final Point2D centroid(java.util.Collection<? extends Point2D> points)
points - a collection of points
public static final Point2D centroid(java.awt.geom.Point2D pt1,
java.awt.geom.Point2D pt2,
java.awt.geom.Point2D pt3)
pt1 - the first pointpt2 - the second pointpt3 - the third point
public double getDistance(java.awt.geom.Point2D point)
point.
getDistance in interface Shape2D
public double getDistance(double x,
double y)
(x,y). Uses the Math.hypot() function for
better robustness than simple square root.
getDistance in interface Shape2Dpublic java.awt.Point getAsInt()
public java.awt.geom.Point2D.Double getAsDouble()
public java.awt.geom.Point2D.Float getAsFloat()
public void setPolarLocation(double rho,
double theta)
public void setPolarLocation(java.awt.geom.Point2D point,
double rho,
double theta)
public boolean isBounded()
isBounded in interface Shape2D
public boolean contains(double x,
double y)
contains in interface java.awt.Shapepublic boolean contains(java.awt.geom.Point2D p)
contains in interface java.awt.Shape
public boolean contains(double x,
double y,
double w,
double h)
contains in interface java.awt.Shapepublic boolean contains(java.awt.geom.Rectangle2D r)
contains in interface java.awt.Shapepublic boolean equals(java.lang.Object obj)
equals in class java.awt.geom.Point2Dpublic Point2D plus(java.awt.geom.Point2D p)
public Point2D minus(java.awt.geom.Point2D p)
public java.awt.Rectangle getBounds()
getBounds in interface java.awt.Shapepublic java.awt.geom.Rectangle2D getBounds2D()
getBounds2D in interface java.awt.Shapepublic java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform t)
getPathIterator in interface java.awt.Shape
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform t,
double flatness)
getPathIterator in interface java.awt.Shape
public boolean intersects(double x,
double y,
double w,
double h)
intersects in interface java.awt.Shapepublic boolean intersects(java.awt.geom.Rectangle2D r)
intersects in interface java.awt.Shapepublic Shape2D getClippedShape(Box2D box)
public Shape2D clip(Box2D box)
clip in interface Shape2Dbox - the clipping box
public Box2D getBoundingBox()
Shape2D
getBoundingBox in interface Shape2Dpublic Shape2D getTransformedShape(AffineTransform2D trans)
public Point2D transform(AffineTransform2D trans)
Shape2D
transform in interface Shape2Dtrans - an affine transform
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||