Intersection

Intersection

Provides static methods for the computation of intersections, projections, sections and similar.

Methods

(static) lineBox(box, line, tolerance) → {Array}

Intersects an infinite line and an axis aligned bounding box.
Parameters:
Name Type Description
box BoundingBox BoundingBox to intersect.
line Line Line for intersection.
tolerance double If tolerance > 0.0, then the intersection is performed against a box that has each side moved out by tolerance.
Returns:
[bool, Interval]
  • (bool) true if the line intersects the box, false if no intersection occurs.
  • (Interval) The chord from line.PointAt(lineParameters.T0) to line.PointAt(lineParameters.T1) is the intersection.
Type
Array

(static) lineCircle(line, circle) → {Array}

Intersects a line with a circle using exact calculations.
Parameters:
Name Type Description
line Line Line for intersection.
circle Circle Circle for intersection.
Returns:
[LineCircleIntersection, double, Array., double, Array.]
  • (LineCircleIntersection) If is returned, only t1 and point1 will have valid values. If is returned, t2 and point2 will also be filled out.
  • (double) Parameter on line for first intersection.
  • (Array.) Point on circle closest to first intersection.
  • (double) Parameter on line for second intersection.
  • (Array.) Point on circle closest to second intersection.
Type
Array

(static) lineCylinder(line, cylinder) → {Array}

Intersects a line with a cylinder using exact calculations.
Parameters:
Name Type Description
line Line Line for intersection.
cylinder Cylinder Cylinder for intersection.
Returns:
[LineCylinderIntersection, Array., Array.]
  • (LineCylinderIntersection) If None is returned, the first point is the point on the line closest to the cylinder and the second point is the point on the cylinder closest to the line. If is returned, the first point is the point on the line and the second point is the same point on the cylinder.
  • (Array.) First intersection point.
  • (Array.) Second intersection point.
Type
Array

(static) lineLine(lineA, lineB) → {Array}

Finds the closest point between two infinite lines.
Parameters:
Name Type Description
lineA Line First line.
lineB Line Second line.
Returns:
[bool, double, double]
  • (bool) true if points are found and false if the lines are numerically parallel. Numerically parallel means the 2x2 matrix: +AoA -AoB-AoB +BoB is numerically singular, where A = (lineA.To - lineA.From) and B = (lineB.To-lineB.From)
  • (double) Parameter on lineA that is closest to lineB. The shortest distance between the lines is the chord from lineA.PointAt(a) to lineB.PointAt(b)
  • (double) Parameter on lineB that is closest to lineA. The shortest distance between the lines is the chord from lineA.PointAt(a) to lineB.PointAt(b)
Type
Array

(static) lineLine(lineA, lineB, tolerance, finiteSegments) → {Array}

Intersects two lines.
Parameters:
Name Type Description
lineA Line First line for intersection.
lineB Line Second line for intersection.
tolerance double If tolerance > 0.0, then an intersection is reported only if the distance between the points is <= tolerance. If tolerance <= 0.0, then the closest point between the lines is reported.
finiteSegments bool If true, the input lines are treated as finite segments. If false, the input lines are treated as infinite lines.
Returns:
[bool, double, double]
  • (bool) true if a closest point can be calculated and the result passes the tolerance parameter test; otherwise false.
  • (double) Parameter on lineA that is closest to LineB. The shortest distance between the lines is the chord from lineA.PointAt(a) to lineB.PointAt(b)
  • (double) Parameter on lineB that is closest to LineA. The shortest distance between the lines is the chord from lineA.PointAt(a) to lineB.PointAt(b)
Type
Array

(static) linePlane(line, plane) → {Array}

Intersects a line and a plane. This function only returns true if the intersection result is a single point (i.e. if the line is coincident with the plane then no intersection is assumed).
Parameters:
Name Type Description
line Line Line for intersection.
plane Plane Plane to intersect.
Returns:
[bool, double]
  • (bool) true on success, false on failure.
  • (double) Parameter on line where intersection occurs. If the parameter is not within the {0, 1} Interval then the finite segment does not intersect the plane.
Type
Array

(static) lineSphere(line, sphere) → {Array}

Intersects a line with a sphere using exact calculations.
Parameters:
Name Type Description
line Line Line for intersection.
sphere Sphere Sphere for intersection.
Returns:
[LineSphereIntersection, Array., Array.]
  • (LineSphereIntersection) If is returned, the first point is the point on the line closest to the sphere and the second point is the point on the sphere closest to the line. If is returned, the first point is the point on the line and the second point is the same point on the sphere.
  • (Array.) First intersection point.
  • (Array.) Second intersection point.
Type
Array

(static) planePlane(planeA, planeB) → {Array}

Intersects two planes and return the intersection line. If the planes are parallel or coincident, no intersection is assumed.
Parameters:
Name Type Description
planeA Plane First plane for intersection.
planeB Plane Second plane for intersection.
Returns:
[bool, Line]
  • (bool) true on success, false on failure.
  • (Line) If this function returns true, the intersectionLine parameter will return the line where the planes intersect.
Type
Array

(static) planePlanePlane(planeA, planeB, planeC) → {Array}

Intersects three planes to find the single point they all share.
Parameters:
Name Type Description
planeA Plane First plane for intersection.
planeB Plane Second plane for intersection.
planeC Plane Third plane for intersection.
Returns:
[bool, Array.]
  • (bool) true on success, false on failure. If at least two out of the three planes are parallel or coincident, failure is assumed.
  • (Array.) Point where all three planes converge.
Type
Array

(static) planeSphere(plane, sphere) → {Array}

Intersects a plane with a sphere using exact calculations.
Parameters:
Name Type Description
plane Plane Plane to intersect.
sphere Sphere Sphere to intersect.
Returns:
[PlaneSphereIntersection, Circle]
  • (PlaneSphereIntersection) If is returned, the intersectionCircle has a radius of zero and the center point is the point on the plane closest to the sphere.
  • (Circle) Intersection result.
Type
Array

(static) sphereSphere(sphereA, sphereB) → {Array}

Intersects two spheres using exact calculations.
Parameters:
Name Type Description
sphereA Sphere First sphere to intersect.
sphereB Sphere Second sphere to intersect.
Returns:
[SphereSphereIntersection, Circle]
  • (SphereSphereIntersection) The intersection type.
  • (Circle) If intersection is a point, then that point will be the center, radius 0.
Type
Array