Click or drag to resize
Point2D Class
The Point class is an immutable data type to encapsulate a two-dimensional point with real-value coordinates. In order to deal with the difference behavior of double with respect to -0.0 and +0.0, the Point2D constructor converts any coordinates that are -0.0 to +0.0.
Inheritance Hierarchy

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public sealed class Point2D : BasicVisual, 
	IComparable<Point2D>

The Point2D type exposes the following members.

Constructors
  NameDescription
Public methodPoint2D
Initializes a new point (x, y).
Top
Properties
  NameDescription
Public propertyR
Returns the polar radius of this point.
Public propertyTheta
Returns the angle of this point in polar coordinates.
Public propertyX
Returns the x-coordinate.
Public propertyY
Returns the y-coordinate.
Top
Methods
  NameDescription
Public methodStatic memberArea2
Returns twice the signed area of the triangle a-b-c.
Public methodStatic memberCcw
Returns true if a->b->c is a counterclockwise turn.
Public methodCompareTo
Compares two points by y-coordinate, breaking ties by x-coordinate. Formally, the invoking point (x0, y0) is less than the argument point (x1, y1) if and only if either y0 < y1 or if y0 = y1 and x0 < x1.
Public methodDistanceSquaredTo
Returns the square of the Euclidean distance between this point and that point.
Public methodDistanceTo
Returns the Euclidean distance between this point and that point.
Public methodDraw
Plot this point using standard draw.
(Overrides BasicVisualDraw.)
Public methodDrawTo
Plot a line from this point to that point using standard draw.
Public methodEquals
Compares this point to the specified point.
(Overrides ObjectEquals(Object).)
Public methodGetAtan2Order
Compares two points by atan2() angle (between -pi and pi) with respect to this point.
Public methodGetDistanceToOrder
Compares two points by distance to this point.
Public methodGetHashCode
Returns an integer hash code for this point.
(Overrides ObjectGetHashCode.)
Public methodGetPolarOrder
Compares two points by polar angle (between 0 and 2pi) with respect to this point.
Public methodStatic memberMainTest
Demo test the point data type.
Public methodToString
Return a string representation of this point.
(Overrides ObjectToString.)
Top
Fields
  NameDescription
Public fieldStatic memberR_ORDER
Compares two points by polar radius.
Public fieldStatic memberX_ORDER
Compares two points by x-coordinate.
Public fieldStatic memberY_ORDER
Compares two points by y-coordinate.
Top
Remarks

For additional documentation, see Section 1.2 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class Point2D implementation by the respective authors.

See Also