Defines a line in two-dimensional coordinates.

Hierarchy

  • Line2d

Implements

Constructors

Properties

_p1: Point2d
_p2: Point2d

Accessors

  • get isHorizontal(): boolean
  • Checks if the line is horizontal.

    Returns boolean

    true is this is the case.

  • get isVertical(): boolean
  • Checks if the line is vertical.

    Returns boolean

    true is this is the case.

  • get length(): number
  • Gets the length of the line.

    Returns number

Methods

  • Gets the angle between the given line.

    Parameters

    • line: Line2d

      The reference line.

    • keepOrientation: boolean = true

      A value indicating if we keep the orientation, aka knowing if the angle is clockwise or not.

    Returns number

    The angle.

  • Checks if the current line intersect with the given shape.

    Parameters

    Returns boolean

    true it the two shapes intersect, otherwise false.

  • Gets a line having the given angle to the current one.

    Parameters

    • angle: number

      The desired angle.

    • length: number = 20

      The length of the line (default value is 20)

    Returns Line2d

    The resulting line.

  • Gets the orthogonal line passing starting at given point on the line.

    Parameters

    • p3: Point2d

      The point to start from.

    • length: number = 20

      Expected length of the line (default value is 20)

    • clockwise: boolean = false

      A value indicating the direction of the line (default value is false)

    Returns Line2d

    The orthogonal line.

  • Gets the orthogonal line passing through the given point.

    Parameters

    • p3: Point2d

      The point to pass through.

    Returns Line2d

    The orthogonal line.

  • Does the current line goes in the same direction as the given one.

    Parameters

    • line: Line2d

      The comparision line.

    Returns boolean

    true if this is the case, otherwise false.

  • Checks if the given point is in the line.

    Parameters

    • point: Point2d

      The reference point.

    • threshold: number = 0

      A value used as a threshold / range to check if the point is on the line.

    Returns boolean

  • Checks if the given point is in the line.

    Parameters

    • point: Point2d

      The reference point.

    • threshold: number = 0

      A value used as a threshold / range to check if the point is on the line.

    Returns boolean

  • Is the current line perpendicular to the given one.

    Parameters

    • line: Line2d

      The comparision line.

    Returns boolean

    true if this the case, otherwise false.

  • Checks if the line is parallel to another one.

    Parameters

    • line: Line2d

      The reference line.

    Returns boolean

    true both lines are parallel.

  • Rotates the line by the given angle in degree, around a point.

    Parameters

    • angle: number

      The rotation angle.

    • origin: Point2d = ...

      The origin from which the rotation is supposed to be done.

    Returns void

  • Translates the line using the given vector for direction.

    Parameters

    • vector: Vector2d

      The vector defining the direction.

    Returns void

  • Gets the angle between two lines.

    Parameters

    • p1x: number

      x-coordinate of the starting point of the first line.

    • p1y: number

      y-coordinate of the starting point of the first line.

    • p2x: number

      x-coordinate of the ending point of the first line.

    • p2y: number

      y-coordinate of the ending point of the first line.

    • p3x: number

      x-coordinate of the starting point of the second line.

    • p3y: number

      y-coordinate of the starting point of the second line.

    • p4x: number

      x-coordinate of the ending point of the second line.

    • p4y: number

      y-coordinate of the ending point of the second line.

    • keepOrientation: boolean = true

      A value indicating if we keep the orientation, aka knowing if the angle is clockwise or not.

    Returns number

  • Gets the length of the line starting at (x1,y1) and closing at (x2,y2).

    Parameters

    • p1x: number

      x coordinate of start of the line.

    • p1y: number

      y coordinate of start of the line.

    • p2x: number

      x coordinate of end of the line.

    • p2y: number

      y coordinate of end of the line.

    Returns number

    The length.

Generated using TypeDoc