DWVv0.37.0

Point2D

Source: point.js:7

Immutable 2D point.


Constructor

new Point2D(x: number, y: number): Point2D

Parameters

  • x (number) — The X coordinate for the point.
  • y (number) — The Y coordinate for the point.

Instance Methods

getX(): number

Get the X position of the point.

Returns

  • number — The X position of the point.

getY(): number

Get the Y position of the point.

Returns

  • number — The Y position of the point.

getValues(): Array.<number>

Get the values of this point.

Returns

  • Array.<number> — The array of values.

getCentroid(): Point2D

Get the centroid of the point, ie itself.

Returns

contains(point: Point2D, tolerance?: number): boolean

Check if a point is at this point, within a tolerance.

Parameters

  • point (Point2D) — The point to check.
  • tolerance (number, optional, default: 0) — Optional maximum distance, defaults to 0.

Returns

  • boolean — True if the point is within tolerance.

equals(rhs: Point2D): boolean

Check for Point2D equality.

Parameters

  • rhs (Point2D) — The other point to compare to.

Returns

  • boolean — True if both points are equal.

toString(): string

Get a string representation of the Point2D.

Returns

  • string — The point as a string.

getDistance(point2D: Point2D): number

Get the distance to another Point2D.

Parameters

  • point2D (Point2D) — The input point.

Returns

  • number — Ths distance to the input point.