|
||||||||||
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.
Important note: in a future release, Point2D will not extend
java.awt.geom.Point2D.Double
any more.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.geom.Point2D |
---|
Point2D.Double, Point2D.Float |
Field Summary | |
---|---|
static Point2D |
INFINITY_POINT
Deprecated. it is recommended to use exceptions instead (0.7.0) |
Fields inherited from class java.awt.geom.Point2D.Double |
---|
x, y |
Fields inherited from interface math.geom2d.Shape2D |
---|
ACCURACY |
Constructor Summary | |
---|---|
Point2D()
Constructs a new Point2D at position (0,0). |
|
Point2D(double x,
double y)
Constructs a new Point2D at the given given position. |
|
Point2D(Point2D point)
Constructs a new Point2D by copying coordinates of given java point. |
|
Point2D(Point2D point1,
double x,
double y)
Deprecated. use Point2D.createPolar() instead (0.7.0) |
|
Point2D(Point2D point1,
Point2D point2)
Deprecated. since 0.7.0 |
Method Summary | |
---|---|
static int |
ccw(Point2D p0,
Point2D p1,
Point2D p2)
Computes the orientation of the 3 points: returns +1 is the path P0->P1->P2 turns Counter-Clockwise, -1 if the path turns Clockwise, and 0 if the point P2 is located on the line segment [P0 P1]. |
static Point2D |
centroid(Collection<? extends Point2D> points)
Computes the centroid, or center of mass, of a collection of points. |
static Point2D |
centroid(Point2D[] points)
Computes the centroid, or center of mass, of an array of points. |
static Point2D |
centroid(Point2D[] points,
double[] weights)
Computes the weighted centroid, or center of mass, of an array of points. |
static Point2D |
centroid(Point2D pt1,
Point2D pt2,
Point2D pt3)
Compute the centroid of three points. |
PointSet2D |
clip(Box2D box)
Returns a PointSet2D, containing 0 or 1 point, depending on whether the point lies inside the specified box. |
Point2D |
clone()
Creates a new Point2D object with same coordinates. |
boolean |
contains(double x,
double y)
Returns true if the two points are equal. |
boolean |
contains(Point2D p)
Returns true if the two points are equal. |
static Point2D |
create(double x,
double y)
Static factory for creating a new point in cartesian coordinates. |
static Point2D |
create(Point2D point)
Static factory for creating a new point from an existing instance of java point. |
static Point2D |
createPolar(double rho,
double theta)
Creates a new point from polar coordinates rho and
theta . |
static Point2D |
createPolar(double x0,
double y0,
double rho,
double theta)
Creates a new point from polar coordinates rho and
theta , from the position (x0,y0). |
static Point2D |
createPolar(Point2D point,
double rho,
double theta)
Creates a new point from polar coordinates rho and
theta , from the given point. |
void |
draw(Graphics2D g2)
Draws the point on the specified Graphics2D, using default radius equal to 1. |
void |
draw(Graphics2D g2,
double r)
Draws the point on the specified Graphics2D, by filling a disc with a given radius. |
boolean |
equals(Object obj)
Two points are considered equal if their Euclidean distance is less than Shape2D.ACCURACY. |
Point2D.Double |
getAsDouble()
Converts point to a double version. |
Point2D.Float |
getAsFloat()
Converts point to a float version. |
Point |
getAsInt()
Converts point to an integer version. |
Box2D |
getBoundingBox()
Returns a bounding box with zero width and zero height, whose coordinates limits are point coordinates. |
CirculinearDomain2D |
getBuffer(double dist)
Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d. |
double |
getDistance(double x,
double y)
Computes the distance between current point and point with coordinate (x,y) . |
static double |
getDistance(double x1,
double y1,
double x2,
double y2)
Computes the Euclidean distance between two points, given by their coordinates. |
double |
getDistance(Point2D point)
Computes the distance between this and the point point . |
static double |
getDistance(Point2D p1,
Point2D p2)
Computes the Euclidean distance between two points. |
int |
getPointNumber()
Returns the number of points in the set. |
Collection<Point2D> |
getPoints()
Returns the points in the shape as a collection. |
boolean |
isBounded()
Returns true if the point is bounded. |
static boolean |
isColinear(Point2D p1,
Point2D p2,
Point2D p3)
Tests if the three points are colinear. |
boolean |
isEmpty()
Returns true if the shape does not contain any point. |
Iterator<Point2D> |
iterator()
|
static Point2D |
midPoint(Point2D p1,
Point2D p2)
|
Point2D |
minus(Point2D p)
|
Point2D |
plus(Point2D p)
|
Point2D |
rotate(double theta)
Rotates the point by a given angle around the origin. |
Point2D |
rotate(Point2D center,
double theta)
Rotates the point by a given angle around an arbitrary center. |
Point2D |
scale(double k)
Returns the new point scaled by the same amount in each direction. |
Point2D |
scale(double kx,
double ky)
Returns the new point scaled by amount given in each direction. |
void |
setPolarLocation(double rho,
double theta)
Deprecated. use Point2D.createPolar() instead (0.7.0) |
void |
setPolarLocation(Point2D point,
double rho,
double theta)
Deprecated. use Point2D.createPolar() instead (0.7.0) |
String |
toString()
|
Point2D |
transform(AffineTransform2D trans)
Returns the transformed point. |
Point2D |
transform(CircleInversion2D inv)
Transforms the shape by a circle inversion. |
Point2D |
translate(double tx,
double ty)
Returns the new point translated by amount given in each direction. |
Methods inherited from class java.awt.geom.Point2D.Double |
---|
getX, getY, setLocation |
Methods inherited from class java.awt.geom.Point2D |
---|
distance, distance, distance, distanceSq, distanceSq, distanceSq, hashCode, setLocation |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
@Deprecated public static final Point2D INFINITY_POINT
Constructor Detail |
---|
public Point2D()
public Point2D(double x, double y)
public Point2D(Point2D point)
@Deprecated public Point2D(Point2D point1, Point2D point2)
@Deprecated public Point2D(Point2D point1, double x, double y)
Method Detail |
---|
public static final Point2D create(double x, double y)
public static final Point2D create(Point2D point)
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).
public static final double getDistance(double x1, double y1, double x2, double y2)
public static final double getDistance(Point2D p1, Point2D p2)
p1
- the first pointp2
- the second point
public static final boolean isColinear(Point2D p1, Point2D p2, Point2D p3)
public static final int ccw(Point2D p0, Point2D p1, Point2D p2)
p0
- the initial pointp1
- the middle pointp2
- the last point
public static final Point2D midPoint(Point2D p1, Point2D p2)
public static final Point2D centroid(Point2D[] points)
points
- an array of points
public static final Point2D centroid(Point2D[] points, double[] weights)
points
- an array of pointsweights
- an array of weights the same size as points
public static final Point2D centroid(Collection<? extends Point2D> points)
points
- a collection of points
public static final Point2D centroid(Point2D pt1, Point2D pt2, Point2D pt3)
pt1
- the first pointpt2
- the second pointpt3
- the third point
public Point2D plus(Point2D p)
public Point2D minus(Point2D p)
public Point2D translate(double tx, double ty)
tx
- the translation in x directionty
- the translation in y direction
public Point2D scale(double kx, double ky)
kx
- the scale factor in x directionky
- the scale factor in y direction
public Point2D scale(double k)
k
- the scale factor
public Point2D rotate(double theta)
theta
- the angle of rotation
public Point2D rotate(Point2D center, double theta)
center
- the center of the rotationtheta
- the angle of rotation
public Point getAsInt()
public Point2D.Double getAsDouble()
public Point2D.Float getAsFloat()
@Deprecated public void setPolarLocation(double rho, double theta)
@Deprecated public void setPolarLocation(Point2D point, double rho, double theta)
public CirculinearDomain2D getBuffer(double dist)
CirculinearShape2D
getBuffer
in interface CirculinearShape2D
dist
- the maximal distance between a point of the buffer and the
shape
public Point2D transform(CircleInversion2D inv)
CirculinearShape2D
transform
in interface CirculinearShape2D
inv
- the circle inversion
public double getDistance(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 Shape2D
public boolean isBounded()
isBounded
in interface Shape2D
public boolean isEmpty()
Shape2D
isEmpty
in interface Shape2D
public boolean contains(double x, double y)
contains
in interface Shape2D
public boolean contains(Point2D p)
contains
in interface Shape2D
public PointSet2D clip(Box2D box)
clip
in interface PointShape2D
clip
in interface Shape2D
box
- the clipping box
public Box2D getBoundingBox()
getBoundingBox
in interface Shape2D
public Point2D transform(AffineTransform2D trans)
transform
in interface PointShape2D
transform
in interface Shape2D
trans
- an affine transform
public void draw(Graphics2D g2)
draw
in interface Shape2D
g2
- the graphics to draw the pointpublic void draw(Graphics2D g2, double r)
g2
- the graphics to draw the pointpublic int getPointNumber()
PointShape2D
getPointNumber
in interface PointShape2D
public Collection<Point2D> getPoints()
PointShape2D
getPoints
in interface PointShape2D
public Iterator<Point2D> iterator()
iterator
in interface Iterable<Point2D>
public String toString()
toString
in class Point2D.Double
public boolean equals(Object obj)
equals
in class Point2D
public Point2D clone()
clone
in class Point2D
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |