Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Intersection

The intersection module contains a set of helper functions to calculate where various geometry intersect.

For the most part, if you want to get the point of intersection between a line and any other type of geometry, you can call this directly (Line.intersection) without using any of this module's functions. The same is true for rays (Ray.intersection) and polylines (Polyline.intersection).

This module is helpful if you need more detailed information about particular intersections. For example, the Intersection.lineLine function calculates where two lines intersect and returns where the intersection occurs relative to each line.

Index

Functions

line

lineBox

  • Calculates which portion of a line is inside a bounding box. Returns the parameter of the interval inside.

    Parameters

    • line: Line

      The line to intersect.

    • box: BoundingBox

      The bounding box that intersects the line.

    Returns { domain: IntervalSorted; intersects: boolean }

    • Readonly domain: IntervalSorted

      The portion of the line within the box. Use Line.pointAt to get actual points. Note that the two ends of the interval aren't always points of intersection – for example, a line could be completely inside a box without touching the sides, in which case the interval would be the full length of the line (0 to 1) but neither 0 nor 1 would be a point of intersection.

    • Readonly intersects: boolean

      True if the line intersects the box.

lineCircle

  • Calculates the points of intersection between a line and a circle.

    Parameters

    • line: Line

      The line to intersect.

    • circle: Circle

      The circle that intersects the line.

    Returns { intersects: LineCircleIntersection; u: keyof number[] }

    • Readonly intersects: LineCircleIntersection

      The number of times the line intersects the circle.

    • Readonly u: keyof number[]

      The parameters along the line where the intersections occur. Use Line.pointAt to get the actual points.

lineLine

  • lineLine(lineA: Line, lineB: Line, limitToFiniteSegment?: boolean): { intersects: boolean; lineAU: number; lineBU: number }
  • Calculates the point of intersection between two lines.

    Parameters

    • lineA: Line

      The first line.

    • lineB: Line

      The second line.

    • Default value limitToFiniteSegment: boolean = true

      If true, an intersection only counts if it falls within the bounds of the lines. If false, the lines are treated as infinite.

    Returns { intersects: boolean; lineAU: number; lineBU: number }

    • Readonly intersects: boolean

      True if the two lines intersect.

    • Readonly lineAU: number

      The parameter along lineA where the intersection occurs. Use Line.pointAt to get the actual point.

    • Readonly lineBU: number

      The parameter along lineB where the intersection occurs. Use Line.pointAt to get the actual point.

polyline

ray

rayBox

  • Calculates which portion of a ray is inside a bounding box. Returns the parameters of the interval inside.

    Parameters

    • ray: Ray

      The ray to intersects.

    • box: BoundingBox

      The bounding box that intersects the ray.

    • Default value range: RayRange = RayRange.both

      The extent of the ray. Specifies whether the ray is shooting both forward and backward, or only forward.

    Returns { domain: IntervalSorted; intersects: boolean }

    • Readonly domain: IntervalSorted

      The portion of the ray within the box. Use Ray.pointAt to get actual points. Note that if you've limited the ray's range to only shoot forward, one value in the interval could be the ray's start rather than the point of intersection.

    • Readonly intersects: boolean

      True if the ray intersects the box.

rayCircle

  • Calculates the points of intersection between a ray and a circle.

    Parameters

    • ray: Ray

      The ray to intersect.

    • circle: Circle

      The circle that intersects the ray.

    • Default value range: RayRange = RayRange.both

      The extent of the ray. Specifies whether the ray is shooting both forward and backward, or only forward.

    Returns { intersects: LineCircleIntersection; u: keyof number[] }

    • Readonly intersects: LineCircleIntersection

      The number of times the ray intersects the circle.

    • Readonly u: keyof number[]

      The parameters along the ray where the intersections occur. Use Ray.pointAt to get the actual points.

rayLine

  • rayLine(ray: Ray, line: Line, range?: RayRange): { intersects: boolean; lineU: number; rayU: number }
  • Calculates the point of intersection between a ray and a line.

    Parameters

    • ray: Ray

      The ray that intersects the line.

    • line: Line

      The line that intersects the ray.

    • Default value range: RayRange = RayRange.both

      The extent of the ray. Specifies whether the ray is shooting both forward and backward, or only forward.

    Returns { intersects: boolean; lineU: number; rayU: number }

    • Readonly intersects: boolean

      True if the ray and line intersect.

    • Readonly lineU: number

      The parameter along line where the intersection occurs. Use Line.pointAt to get the actual point.

    • Readonly rayU: number

      The parameter along ray where the intersection occurs. Use Ray.pointAt to get the actual point.

rayRay

  • rayRay(rayA: Ray, rayB: Ray, range?: RayRange): { intersects: boolean; rayAU: number; rayBU: number }
  • Calculates the point of intersection between two rays.

    Parameters

    • rayA: Ray

      The first ray.

    • rayB: Ray

      The second ray.

    • Default value range: RayRange = RayRange.both

      The extent of the ray. Specifies whether the ray is shooting both forward and backward, or only forward.

    Returns { intersects: boolean; rayAU: number; rayBU: number }

    • Readonly intersects: boolean

      True if the two rays intersect.

    • Readonly rayAU: number

      The parameter along rayA where the intersection occurs. Use Ray.pointAt to get the actual point.

    • Readonly rayBU: number

      The parameter along rayB where the intersection occurs. Use Ray.pointAt to get the actual point.

Generated using TypeDoc