Class representing a point

Hierarchy (view full)

Implements

Constructors

  • Point may be constructed by two numbers, or by array of two numbers

    Parameters

    • Rest...args: [number, number] | [] | [[number, number]]

      array of two numbers or two numbers

    Returns Point

Properties

x: number = 0

x-coordinate of a point (float number)

y: number = 0

y-coordinate of a point (float number)

Accessors

  • get box(): Box
  • Returns

    Returns Box

    bounding box of a point

  • get name(): string
  • Shape name

    Returns string

    name of the shape

  • get vertices(): Point[]
  • Returns Point[]

Methods

  • Return new cloned instance of point

    Returns Point

  • Calculate distance and shortest segment from point to shape and return as array [distance, shortest segment]

    Parameters

    • shape: Shape<any> | Polygon

      Shape of the one of supported types Point, Line, Circle, Segment, Arc, Polygon or Planar Set

    Returns [number, Segment]

    distance from point to shape

  • Returns true if points are equal up to [DP_TOL]Config tolerance

    Parameters

    Returns boolean

  • Returns true if point belongs to the "left" semi-plane, which means, point belongs to the same semi plane where line normal vector points to Return false if point belongs to the "right" semi-plane or to the line itself

    Parameters

    • line: Line

      Query line

    Returns boolean

    true if point belongs to the "left" semi-plane

  • Defines predicate "less than" between points. Returns true if the point is less than query points, false otherwise
    By definition point1 < point2 if {point1.y < point2.y || point1.y == point2.y && point1.x < point2.x
    Numeric values compared with [DP_TOL]Config tolerance

    Parameters

    Returns boolean

  • Check if point belongs to the shape

    Parameters

    Returns boolean

    Returns true if point is on a shape, false otherwise

  • Returns projection point on given line

    Parameters

    • line: Line

      Line this point be projected on

    Returns Point

  • Rotate shape by given angle around given center point. If center point is omitted, rotates around zero point (0,0). Positive value of angle defines rotation in counterclockwise direction, negative angle defines rotation in clockwise direction

    Parameters

    • angle: number

      angle in radians

    • center: SimplePoint = ...

      center of rotation

    Returns Point

    new rotated shape

  • Scale shape with coordinates multiplied by scaling factor

    Parameters

    • sx: number

      x-axis scaling factor

    • sy: number

      y-axis scaling factor

    Returns Point

    new scaled shape

  • Return new point transformed by affine transformation matrix

    Parameters

    • m: Matrix

      affine transformation matrix (a,b,c,d,tx,ty)

    Returns Point

    Transformed point

  • Translated shape by given vector. Translation vector may be also defined by a pair of numbers.

    Parameters

    • Rest...args: [number, number] | [Vector]

      Translation vector or translation by x and y or tuple of numbers

    Returns Point

    new translated shape