Class LineSegment

A LineSegment is defined by two points, it represents the line between these points.

Constructors

Properties

p1: Point
p2: Point

Methods

  • Gets the closest point on the line segment to the given point.

    Parameters

    • p2: Point

      Point to get closest point for.

    Returns Point

  • Returns if the given point exists on this line segment or not.

    Parameters

    Returns boolean

  • Return true if the points of this line segment equals the points of the other line segment.

    Parameters

    Returns boolean

  • Returns the point where the given line segments intersect, if such point exists. If the line segments are parallel none is return since the intersect can potentially be many points.

    Parameters

    • ls2: LineSegment

      The other line segment.

    • otherInterval: IntervalType = IntervalType.Closed

      How the endpoints should be interpreted of the other line segment.

    • thisInterval: IntervalType = IntervalType.Closed

      How the endpoints should be interpreted on this line segment.

    Returns Optional<Point>

  • Returns the point where the given line intersect this line segment, if such point exists. If the line and the line segment are parallel and on the same line, none is returned because there is no one unique point of intersect.

    Parameters

    Returns Optional<Point>

  • Verifies if the given point is on the line that would be defined by p1 and p2 of this line segment.

    Parameters

    • p: Point

      The point to verify

    Returns boolean

  • Verifies if the given point is on the line segment defined by p1 and p2.

    Parameters

    • p: Point

      The point to verify

    Returns boolean

  • Checks if there is any overlapping point between the two line segments. This is like intersect, but returns a boolean and will also return true if the line segments are parallel and share one or more common points.

    Parameters

    Returns boolean

  • Checks if this line segment is parallel to another line segment. Parallel will also hold true if the line segments overlap, or lie on the same axis. I.e. [0,0] -> [1,0] is deemed parallel to [1,0] -> [2,0]

    Parameters

    • other: LineSegment

      The line segment to do the comparison on.

    Returns boolean

  • Returns boolean whether this segment is placed to the right of given point. This is defined as if whether a line segment starting at point p, and going to x = infinity, intersect this line segment. If the point is on the line segment, false is returned,

    Parameters

    • p: Point

      Point to check if line segemnt is to the right of

    • intervalType: IntervalType = IntervalType.OpenEnd

      Tells us if endpoints should be part of interval or not.

    Returns boolean

  • Gives a string representing this line segment that's readable.

    Returns string

  • Creates a LineSegment from an array of numbers. The array must be at least 4 elements long and these first 4 values will be used as [x1, y1, x2, y2].

    Parameters

    • a: number[]

    Returns LineSegment

  • Creates a LineSegment from four numbers. The first two being x and y from the start point of the line segment, the last two the x and y value of the end point.

    Parameters

    • x1: number
    • y1: number
    • x2: number
    • y2: number

    Returns LineSegment

Generated using TypeDoc