@svizzle/geometry/2DPoint

Methods

(static) getDistance2D(point, point) → {number}

Source:
Since:
  • 0.1.0

Return the distance between two 2D points

Example
> getDistance2D({x: 1, y: 1}, {x: 2, y: 2})
1.4142135623730951
Parameters:
Name Type Description
point object

The first point

point object

The second point

Returns:
  • The distance between the two points
Type
number

(static) getTwoPointsCenter(point, point) → {object}

Source:
Since:
  • 0.1.0

Return the center of two 2D points

Example
> getTwoPointsCenter({x: 1, y: 1}, {x: 3, y: 3})
{x: 2, y: 2}
Parameters:
Name Type Description
point object

The first point

point object

The second point

Returns:

point - The center point

Type
object

(static) makePosition2D(pointArray) → {object}

Source:
Since:
  • 0.1.0

Creates a position object from an array of 2 numbers

Example
> makePosition2D([1, 2])
{x: 1, y: 2}
Parameters:
Name Type Description
pointArray array

An array of 2 numbers

Returns:
  • An object with {x, y} coordinates.
Type
object