com.esri.core.geometry

## Class Point2D

• All Implemented Interfaces:
Serializable

```public final class Point2D
extends Object
implements Serializable```
Basic 2D point class. Contains only two double fields.
Serialized Form
• ### Field Summary

Fields
Modifier and Type Field and Description
`double` `x`
`double` `y`
• ### Constructor Summary

Constructors
Constructor and Description
`Point2D()`
```Point2D(double x, double y)```
`Point2D(Point2D other)`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`void` `add(Point2D other)`
`void` ```add(Point2D p1, Point2D p2)```
`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.
`static Point2D` ```construct(double x, double y)```
`double` `crossProduct(Point2D other)`
`static double` ```distance(Point2D pt1, Point2D pt2)```
`double` `dotProduct(Point2D other)`
`boolean` `equals(Object other)`
`boolean` `equals(Point2D other)`
`int` `getQuarter()`
Calculates which quarter of XY plane the vector lies in.
`int` `hashCode()`
`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)`
`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 + shift
`void` ```scaleAdd(double f, Point2D other, Point2D shift)```
Calculates this = other * f + shift
`void` ```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)```
`String` `toString()`
• ### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### 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(Object other)`
Overrides:
`equals` in class `Object`
• #### sub

`public void sub(Point2D other)`
• #### sub

```public void sub(Point2D p1,
Point2D p2)```

`public void add(Point2D other)`

```public void add(Point2D p1,
Point2D p2)```
• #### negate

`public void negate()`
• #### negate

`public void negate(Point2D other)`
• #### interpolate

```public void interpolate(Point2D other,
double alpha)```
• #### interpolate

```public void interpolate(Point2D p1,
Point2D p2,
double alpha)```

```public void scaleAdd(double f,
Point2D shift)```
Calculates this = this * f + shift
Parameters:
`f` -
`shift` -

```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.
• #### normalize

`public void normalize(Point2D other)`
• #### normalize

`public void normalize()`
• #### length

`public double length()`
• #### sqrLength

`public double sqrLength()`
• #### distance

```public static double distance(Point2D pt1,
Point2D pt2)```
• #### dotProduct

`public double dotProduct(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)).
• #### 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.
• #### sqrDistance

```public static double sqrDistance(Point2D pt1,
Point2D pt2)```
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`
• #### setNaN

`public void setNaN()`
• #### isNaN

`public boolean isNaN()`
• #### 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.
• #### hashCode

`public int hashCode()`
Overrides:
`hashCode` in class `Object`