Copyright © 2021 by K4.org
  (v.0.48.124)

Line is a pure geometry object. It is used for geometric computations within rules. It is based on the three.js Line3 object.

Note: use R.makeLine(p0, p1) to create a Line primitive between two Point primitives p0 and p1. You can use new Line(line3) if you have a three.js Line3 object (which should be rare).

Hierarchy

Implements

  • IKnown

Index

Accessors

direction

direction:

Return the vector from p0 to p1.

length

length:

Return the length of the Line.

p0

p0:

p1

p1:

Methods

collinear

  • collinear(otherLine: Line): boolean
  • Returns true if the lines are collinear with each other.

    Parameters

    Returns boolean

contains

  • contains(p: Point, clamp?: boolean): boolean
  • Returns true if the given point is on this line. If clamp is true, only returns true if it is on this line segment.

    Parameters

    • p: Point
    • Optional clamp: boolean

    Returns boolean

describe

  • describe(): string
  • Returns a human-readable description as a string in the form line[p0<0, 0, 0>, p1<1, 0, 0>]

    Note that the numbers returned are for display purposes only, and are not precise enough to guarantee exact re-creation.

    Returns string

drop

  • Drops p on this, returning the closest point. If clamp is true, returns the nearest point on this line segment.

    Parameters

    • p: Point
    • Optional clamp: boolean

    Returns Point

get3

  • get3(): Line3
  • Returns the three.js implementation object

    Returns Line3

intersectLine

  • intersectLine(line: Line, infinite?: boolean, project?: boolean): GeomResult
  • Performs a 3D line intersection. Possible outcomes:

    1. Point of intersection on this line (status: regular)
    2. Collinear line (parallel and point in common) (status: degenerate)
    3. No intersection (parallel, skew lines or intersection not on segments) (status: empty)

    Parameters

    • line: Line

      The Line to intersect with this one.

    • Optional infinite: boolean

      Defaults to false. If false, restricts the intersection to the line segments of each.

    • Optional project: boolean

      Defaults to false. If true, returns the projection of the intersection on this line along the normal defined by the cross product of the lines' directions.

    Returns GeomResult

intersectLineSegment

  • intersectLineSegment(line: Line): GeomResult
  • This is like intersectLine, except it is uses lengthEpsilon to include intersections that might be within tolerance but fail in the more strict function. Note: This is not faster than intersectLine, since this calls it.

    Parameters

    • line: Line

      The segment to intersect.

    Returns GeomResult

parallel

  • parallel(otherLine: Line): boolean
  • This return true if the two lines are parallel or anti-parallel. If you need to make the distinction, take the dot product of their directions.

    Parameters

    • otherLine: Line

      The Line to compare against.

    Returns boolean

pointAt

  • pointAt(u: number): Point
  • Returns the point at the given distance from p0.

    Parameters

    • u: number

      Parameter as distance from p0.

    Returns Point

    Point along this at u from p0.

same

  • same(line: Line): boolean
  • Returns true if the lines are within lengthEpsilon of each other.

    Parameters

    • line: Line

      Line to compare to.

    Returns boolean