Package com.esri.core.geometry
Class Point2D
- java.lang.Object
-
- com.esri.core.geometry.Point2D
-
- All Implemented Interfaces:
java.io.Serializable
public final class Point2D extends java.lang.Object implements java.io.Serializable
Basic 2D point class. Contains only two double fields.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
Point2D.CompareVectors
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
double
x
double
y
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static int
_compareVectors(Point2D v1, Point2D v2)
(package private) double
_dotProductAbs(Point2D other)
(package private) int
_getQuarter()
(package private) boolean
_isNan()
(package private) double
_norm(int metric)
(package private) void
_setNan()
void
add(Point2D other)
void
add(Point2D p1, Point2D p2)
private static Point2D
calculateCenterFromThreePointsHelper_(Point2D from, Point2D mid_point, Point2D to)
private static Point2D
calculateCenterFromThreePointsHelperMP_(Point2D from, Point2D mid_point, Point2D to)
(package private) static Point2D
calculateCircleCenterFromThreePoints(Point2D from, Point2D mid_point, Point2D to)
int
compare(Point2D other)
Compares two vertices lexicographically by y.static int
compareVectors(Point2D v1, Point2D v2)
Assume vector v1 and v2 have same origin.(package private) int
compareX(Point2D other)
Compares two vertices lexicographically by x.static Point2D
construct(double x, double y)
double
crossProduct(Point2D other)
static double
distance(Point2D pt1, Point2D pt2)
double
dotProduct(Point2D other)
boolean
equals(Point2D other)
boolean
equals(java.lang.Object other)
(package private) double
getAxis(int ordinate)
int
getQuarter()
Calculates which quarter of XY plane the vector lies in.int
hashCode()
(package private) static int
inCircleRobust(Point2D p, Point2D q, Point2D r, Point2D s)
Calculates if the point s is inside of the circumcircle inscribed by the clockwise oriented triangle p-q-r.private static int
inCircleRobustMP_(Point2D p, Point2D q, Point2D r, Point2D s)
void
interpolate(Point2D other, double alpha)
void
interpolate(Point2D p1, Point2D p2, double alpha)
boolean
isEqual(double x_, double y_)
boolean
isEqual(Point2D other)
boolean
isEqual(Point2D other, double tol)
boolean
isNaN()
void
leftPerpendicular()
90 degree rotation, anticlockwise.void
leftPerpendicular(Point2D pt)
90 degree rotation, anticlockwise.double
length()
void
negate()
void
negate(Point2D other)
void
normalize()
void
normalize(Point2D other)
(package private) double
offset(Point2D pt1, Point2D pt2)
returns signed distance of point from infinite line represented by pt_1...pt_2.static int
orientationRobust(Point2D p, Point2D q, Point2D r)
Calculates the orientation of the triangle formed by p, q, r.void
rightPerpendicular()
270 degree rotation, anticlockwise.void
rightPerpendicular(Point2D pt)
270 degree rotation, anticlockwise.void
rotateDirect(double Cos, double Sin)
void
rotateReverse(double Cos, double Sin)
void
scale(double f)
void
scale(double f, Point2D other)
void
scaleAdd(double f, Point2D shift)
Calculates this = this * f + shiftvoid
scaleAdd(double f, Point2D other, Point2D shift)
Calculates this = other * f + shiftvoid
setCoords(double x, double y)
void
setCoords(Point2D other)
void
setNaN()
static double
sqrDistance(Point2D pt1, Point2D pt2)
double
sqrLength()
void
sub(Point2D other)
void
sub(Point2D p1, Point2D p2)
java.lang.String
toString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
x
public double x
-
y
public double y
-
-
Constructor Detail
-
Point2D
public Point2D()
-
Point2D
public Point2D(double x, double y)
-
Point2D
public Point2D(Point2D other)
-
-
Method Detail
-
construct
public static Point2D construct(double x, double y)
-
setCoords
public void setCoords(double x, double y)
-
setCoords
public void setCoords(Point2D other)
-
isEqual
public boolean isEqual(Point2D other)
-
isEqual
public boolean isEqual(double x_, double y_)
-
isEqual
public boolean isEqual(Point2D other, double tol)
-
equals
public boolean equals(Point2D other)
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
sub
public void sub(Point2D other)
-
add
public void add(Point2D other)
-
negate
public void negate()
-
negate
public void negate(Point2D other)
-
interpolate
public void interpolate(Point2D other, double alpha)
-
scaleAdd
public void scaleAdd(double f, Point2D shift)
Calculates this = this * f + shift- Parameters:
f
-shift
-
-
scaleAdd
public void scaleAdd(double f, Point2D other, Point2D shift)
Calculates this = other * f + shift- Parameters:
f
-other
-shift
-
-
scale
public void scale(double f, Point2D other)
-
scale
public void scale(double f)
-
compare
public int compare(Point2D other)
Compares two vertices lexicographically by y.
-
compareX
int compareX(Point2D other)
Compares two vertices lexicographically by x.
-
normalize
public void normalize(Point2D other)
-
normalize
public void normalize()
-
length
public double length()
-
sqrLength
public double sqrLength()
-
dotProduct
public double dotProduct(Point2D other)
-
_dotProductAbs
double _dotProductAbs(Point2D other)
-
crossProduct
public double crossProduct(Point2D other)
-
rotateDirect
public void rotateDirect(double Cos, double Sin)
-
rotateReverse
public void rotateReverse(double Cos, double Sin)
-
leftPerpendicular
public void leftPerpendicular()
90 degree rotation, anticlockwise. Equivalent to RotateDirect(cos(pi/2), sin(pi/2)).
-
leftPerpendicular
public void leftPerpendicular(Point2D pt)
90 degree rotation, anticlockwise. Equivalent to RotateDirect(cos(pi/2), sin(pi/2)).
-
rightPerpendicular
public void rightPerpendicular()
270 degree rotation, anticlockwise. Equivalent to RotateDirect(-cos(pi/2), sin(-pi/2)).
-
rightPerpendicular
public void rightPerpendicular(Point2D pt)
270 degree rotation, anticlockwise. Equivalent to RotateDirect(-cos(pi/2), sin(-pi/2)).
-
_setNan
void _setNan()
-
_isNan
boolean _isNan()
-
_getQuarter
final int _getQuarter()
-
getQuarter
public int getQuarter()
Calculates which quarter of XY plane the vector lies in. First quarter is between vectors (1,0) and (0, 1), second between (0, 1) and (-1, 0), etc. The quarters are numbered counterclockwise. Angle intervals corresponding to quarters: 1 : [0 : 90); 2 : [90 : 180); 3 : [180 : 270); 4 : [270 : 360)
-
compareVectors
public static int compareVectors(Point2D v1, Point2D v2)
Assume vector v1 and v2 have same origin. The function compares the vectors by angle in the counter clockwise direction from the axis X. For example, V1 makes 30 degree angle counterclockwise from horizontal x axis V2, makes 270, V3 makes 90, then compareVectors(V1, V2) == -1. compareVectors(V1, V3) == -1. compareVectors(V2, V3) == 1.- Returns:
- Returns 1 if v1 is less than v2, 0 if equal, and 1 if greater.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setNaN
public void setNaN()
-
isNaN
public boolean isNaN()
-
_norm
double _norm(int metric)
-
offset
double offset(Point2D pt1, Point2D pt2)
returns signed distance of point from infinite line represented by pt_1...pt_2. The returned distance is positive if this point lies on the right-hand side of the line, negative otherwise. If the two input points are equal, the (positive) distance of this point to p_1 is returned.
-
orientationRobust
public static int orientationRobust(Point2D p, Point2D q, Point2D r)
Calculates the orientation of the triangle formed by p, q, r. Returns 1 for counter-clockwise, -1 for clockwise, and 0 for collinear. May use high precision arithmetics for some special degenerate cases.
-
inCircleRobust
static int inCircleRobust(Point2D p, Point2D q, Point2D r, Point2D s)
Calculates if the point s is inside of the circumcircle inscribed by the clockwise oriented triangle p-q-r. Returns 1 for outside, -1 for inside, and 0 for cocircular. Note that the convention used here differs from what is commonly found in literature, which can define the relation in terms of a counter-clockwise oriented circle, and this flips the sign (think of the signed volume of the tetrahedron). May use high precision arithmetics for some special cases.
-
calculateCenterFromThreePointsHelperMP_
private static Point2D calculateCenterFromThreePointsHelperMP_(Point2D from, Point2D mid_point, Point2D to)
-
calculateCenterFromThreePointsHelper_
private static Point2D calculateCenterFromThreePointsHelper_(Point2D from, Point2D mid_point, Point2D to)
-
calculateCircleCenterFromThreePoints
static Point2D calculateCircleCenterFromThreePoints(Point2D from, Point2D mid_point, Point2D to)
-
getAxis
double getAxis(int ordinate)
-
-