A class to test collisions.

Available since

0.1.0

.

Static methods

staticcheckRays(p1:Point, p2:Point, p3:Point, p4:Point, ?outIntersection:Point):Int

Checks if two rays intersects, and where.

If it returns a number >= 0, they intersects.

Parameters:

p1

Point A of a segment on the first ray.

p2

Point B of a segment on the first ray.

p3

Point A of a segment on the second ray.

p4

Point B of a segment on the second ray.

outIntersection

If set, this point will be set to the intersection coordinate.

Returns:

3 if the two rays intersects on both segments, 2 if the two rays intersects on the segment of the second ray, 1 if they intersects on the segment of the first ray, 0 if they intersects but not on any of the two segments, -1 if they don't intersect.

staticcheckSegments(p1:Point, p2:Point, p3:Point, p4:Point, ?outIntersection:Point, ?outOverlap:Segment):Int

Checks if two segments intersects, and where.

If it returns a number > 0, they intersects.

Parameters:

p1

Point A of the first segment.

p2

Point B of the first segment.

p3

Point A of the seocnd segment.

p4

Point B of the seocnd segment.

outIntersection

If set, this point will be set to contain the intersection coordinate.

outOverlap

If set, this segment will be set to contain the overlapping part of the two segments.

Returns:

2 if the segments are colinear and overlaps, 1 if they intersects on a point, 0 if they are colinear but disjoint, -1 if they are parallel and don't intersect, -2 if they are not parallel and don't intersect.

staticgetIntersections(shape1:Shape, shape2:Shape, ?relativeTo:Object):Array<Point>

Returns the intersection points between two shapes.

Those two shapes should be in the same scene, otherwise the result is undefined.

Parameters:

shape1

The first nb.shape.Shape instance.

shape2

The second nb.shape.Shape instance.

relativeTo

The intersection points be will be in this object's coordinate space. If null, the intersection points will be in the coordinate space of shape1's scene.

Returns:

An array containing the intersection points. null if there's no function implemented for these two shape types.

staticgetIntersectionsCirCir(cir1:Circle, cir2:Circle, ?relativeTo:Object):Array<Point>

Returns the intersection points between two circles.

Those two shapes should be in the same scene, otherwise the result is undefined.

Parameters:

cir1

A first nb.shape.Circle instance.

cir2

A second nb.shape.Circle instance.

relativeTo

The intersection points be will be in this object's coordinate space. If null, the intersection points will be in the coordinate space of cir1's scene.

Returns:

An array containing the intersection points.

staticgetIntersectionsPolCir(pol:Polygon, cir:Circle, ?relativeTo:Object):Array<Point>

Returns the intersection points between a polygon and a circle.

Those two shapes should be in the same scene, otherwise the result is undefined.

Parameters:

pol

An nb.shape.Polygon instance.

cir

An nb.shape.Circle instance.

relativeTo

The intersection points be will be in this object's coordinate space. If null, the intersection points will be in the coordinate space of pol's scene.

Returns:

An array containing the intersection points.

staticgetIntersectionsPolPol(pol1:Polygon, pol2:Polygon, ?relativeTo:Object):Array<Point>

Returns the intersection points between two polygons.

Those two shapes should be in the same scene, otherwise the result is undefined.

Parameters:

pol1

A first nb.shape.Polygon instance.

pol2

A second nb.shape.Polygon instance.

relativeTo

The intersection points be will be in this object's coordinate space. If null, the intersection points will be in the coordinate space of pol1's scene.

Returns:

An array containing the intersection points.

staticgetIntersectionsSegCir(seg:Segment, circle:Circle):Array<Point>

Returns the intersection points between a segment and a circle.

The segment and circle should be in the same coordinate space.

Parameters:

seg

An h2d.col.Segment instance.

circle

An h2d.col.Circle instance.

Returns:

An array containing the intersection points.