Class: Point

Point

Represents a 2d point.
Can be created in serveral ways:

new Point() [source]

var point = new Point(1000, 1000);
var point = new Point([1000,1000]);
var point = new Point({x:1000, y:1000});
Extends:

Members

  • x

  • Properties:
    Name Type Description
    x Number x value
    Overrides:
    Source:

  • y

  • Properties:
    Name Type Description
    y Number y value
    Overrides:
    Source:

    Methods

  • closeTo(p, delta) [source]

  • Compare with another point with a delta
    Parameter Type Description
    p Point
    delta Number
    Returns:
    Boolean:
  • mag() [source]

  • Return the magitude of this point: this is the Euclidean distance from the 0, 0 coordinate to this point's x and y coordinates.
    Returns:
    Number: magnitude
  • unit() [source]

  • Calculate this point but as a unit vector from 0, 0, meaning that the distance from the resulting point to the 0, 0 coordinate will be equal to 1 and the angle from the resulting point to the 0, 0 coordinate will be the same as before.
    Returns:
    Point: unit vector point
  • perp() [source]

  • Compute a perpendicular point, where the new y coordinate is the old x coordinate and the new x coordinate is the old y coordinate multiplied by -1
    Returns:
    Point: perpendicular point
  • angleWith(b) [source]

  • Get the angle between this point and another point, in radians from mapbox/point-geometry
    Parameter Type Description
    b Point the other point
    Returns:
    Number: angle
  • rotate(a) [source]

  • Rotate this point around the 0, 0 origin by an angle a, given in radians from mapbox/point-geometry
    Parameter Type Description
    a Number angle to rotate around, in radians
    Returns:
    Point: output point
  • (inherited) set() [source]

  • Set point or coordinate's x, y value
    Inherited From:
    Returns:
    Coordinate|Point: this
  • (inherited) abs() [source]

  • Return abs value of the point
    Inherited From:
    Returns:
    Coordinate|Point: abs point
  • (inherited) round() [source]

  • Like math.round, rounding the point's xy.
    Inherited From:
    Returns:
    Coordinate|Point: rounded point
  • (inherited) distanceTo(point) [source]

  • Returns the distance between the current and the given point.
    Parameter Type Description
    point Coordinate | Point another point
    Inherited From:
    Returns:
    Number: distance
  • (inherited) copy() [source]

  • Returns a copy of the coordinate
    Inherited From:
    Returns:
    Coordinate|Point: copy
  • (inherited) add(x, yopt) [source]

  • Returns the result of addition of another coordinate.
    Parameter Type Description
    x Coordinate | Point | Array | Number coordinate to add
    y opt Number optional, coordinate to add
    Inherited From:
    Returns:
    Coordinate|Point: result
  • (inherited) sub(x, yopt) [source]

  • Returns the result of subtraction of another coordinate.
    Parameter Type Description
    x Coordinate | Point | Array | Number coordinate to add
    y opt Number optional, coordinate to add
    Inherited From:
    Returns:
    Coordinate|Point: result
  • (inherited) substract(x, yopt) [source]

  • Alias for sub
    Parameter Type Description
    x Coordinate | Point | Array | Number coordinate to add
    y opt Number optional, coordinate to add
    Inherited From:
    Returns:
    Coordinate|Point: result
  • (inherited) multi(ratio) [source]

  • Returns the result of multiplication of the current coordinate by the given number.
    Parameter Type Description
    ratio Number ratio to multi
    Inherited From:
    Returns:
    Coordinate|Point: result
  • (inherited) div(n) [source]

  • Returns the result of division of the current point by the given number.
    Parameter Type Description
    n Number number to div
    Inherited From:
    Returns:
    Coordinate|Point: result
  • (inherited) equals(c) [source]

  • Compare with another coordinate to see whether they are equal.
    Parameter Type Description
    c Coordinate | Point coordinate to compare
    Inherited From:
    Returns:
    Boolean:
  • (inherited) isZero() [source]

  • Whether the coordinate/point is zero
    Inherited From:

  • (inherited) toArray() [source]

  • Convert to a number array [x, y]
    Inherited From:
    Returns:
    Array.<Number>: number array
  • (inherited) toFixed(n) [source]

  • Formats coordinate number using fixed-point notation.
    Parameter Type Description
    n Number The number of digits to appear after the decimal point
    Inherited From:
    Returns:
    Coordinate: fixed coordinate
  • (inherited) toJSON() [source]

  • Convert to a json object {x : .., y : ..}
    Inherited From:
    Returns:
    Object: json