Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Line

A 2D line segment

Hierarchy

  • Line

Index

Constructors

constructor

Properties

begin

begin: Vector

The starting point of the line segment

end

end: Vector

The ending point of the line segment

Accessors

intercept

  • get intercept(): number
  • Gets the Y-intercept (b) of the line. Will return (+/-)Infinity if there is no intercept.

    Returns number

midpoint

slope

  • get slope(): number
  • Gets the raw slope (m) of the line. Will return (+/-)Infinity for vertical lines.

    Returns number

Methods

distanceToPoint

  • distanceToPoint(point: Vector): number

findPoint

  • findPoint(x?: number, y?: number): Vector
  • Finds a point on the line given only an X or a Y value. Given an X value, the function returns a new point with the calculated Y value and vice-versa.

    Parameters

    • Default value x: number = null

      The known X value of the target point

    • Default value y: number = null

      The known Y value of the target point

    Returns Vector

    A new point with the other calculated axis value

findVectorToPoint

flip

getEdge

getLength

  • getLength(): number

getSlope

hasPoint

  • hasPoint(x: number, y: number, threshold?: number): boolean
  • hasPoint(v: Vector, threshold?: number): boolean
  • Whether or not the given point lies on this line. This method is precise by default meaning the point must lie exactly on the line. Adjust threshold to loosen the strictness of the check for floating-point calculations.

    see

    http://stackoverflow.com/a/11908158/109458

    Parameters

    • x: number
    • y: number
    • Optional threshold: number

    Returns boolean

  • Whether or not the given point lies on this line. This method is precise by default meaning the point must lie exactly on the line. Adjust threshold to loosen the strictness of the check for floating-point calculations.

    see

    http://stackoverflow.com/a/11908158/109458

    Parameters

    • v: Vector
    • Optional threshold: number

    Returns boolean

normal