Skip to main content

Class: IntersectionUtils

Utils.IntersectionUtils

Class that provides a set of utilities for calculating intersections between 2D and 3D geometric objects.

Methods​

line_boxAABB​

▸ Static line_boxAABB(rayOrigin, rayDir, box): boolean

Checks if a 3D line intersects an Axis-Aligned Bounding Box (AABB) defined by box.

Parameters​

NameTypeDescription
rayOriginVector3The origin of the line.
rayDirVector3The direction of the line.
boxBox3The AABB to check for intersection with.

Returns​

boolean

true if the line intersects the AABB, otherwise false.

Defined in​

src/utils/IntersectionUtils.ts:103


line_line_2D​

▸ Static line_line_2D(a1, a2, b1, b2, target?): Vector3

Computes the intersection between two 2D lines defined by points a1 and a2, and b1 and b2.

Parameters​

NameTypeDescription
a1VectorObject3DThe first point of the first line.
a2VectorObject3DThe second point of the first line.
b1VectorObject3DThe first point of the second line.
b2VectorObject3DThe second point of the second line.
targetVector3(Optional) The vector to store the intersection point. If omitted, a new vector will be created.

Returns​

Vector3

The intersection point of the two lines or undefined if the lines are parallel.

See

https://paulbourke.net/geometry/pointlineplane/

Defined in​

src/utils/IntersectionUtils.ts:22


line_line_3D​

▸ Static line_line_3D(a1, a2, b1, b2, target?, tolerance?): Vector3

Computes the intersection between two 3D lines defined by points a1 and a2, and b1 and b2.

Parameters​

NameTypeDescription
a1ObjVec3The first point of the first line.
a2ObjVec3The second point of the first line.
b1ObjVec3The first point of the second line.
b2ObjVec3The second point of the second line.
targetVector3(Optional) The vector to store the intersection point. If omitted, a new vector will be created.
tolerancenumber(Optional) The tolerance for evaluating the intersection. The default value is 10^-6.

Returns​

Vector3

The intersection point of the two lines or undefined if the lines are parallel or do not intersect.

See

https://paulbourke.net/geometry/pointlineplane/

Defined in​

src/utils/IntersectionUtils.ts:65


segment_boxAABB​

▸ Static segment_boxAABB(p1, p2, box): boolean

Checks if a 3D line segment defined by points p1 and p2 intersects an Axis-Aligned Bounding Box (AABB) defined by box.

Parameters​

NameTypeDescription
p1Vector3The first point of the segment.
p2Vector3The second point of the segment.
boxBox3The AABB to check for intersection with.

Returns​

boolean

true if the segment intersects the AABB and is within the segment's length, otherwise false.

Defined in​

src/utils/IntersectionUtils.ts:160


segment_segment_2D​

▸ Static segment_segment_2D(a1, a2, b1, b2, target?): Vector3

Computes the intersection between two 2D line segments defined by points a1 and a2, and b1 and b2.

Parameters​

NameTypeDescription
a1VectorObject3DThe first point of the first segment.
a2VectorObject3DThe second point of the first segment.
b1VectorObject3DThe first point of the second segment.
b2VectorObject3DThe second point of the second segment.
targetVector3(Optional) The vector to store the intersection point. If omitted, a new vector will be created.

Returns​

Vector3

The intersection point of the two segments or undefined if the segments do not intersect.

See

https://paulbourke.net/geometry/pointlineplane/

Defined in​

src/utils/IntersectionUtils.ts:42