class Collision
package nb.phys
A class to test collisions.
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 |
---|---|
shape2 | The second |
relativeTo | The intersection points be will be in this object's coordinate space.
If |
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 |
---|---|
cir2 | A second |
relativeTo | The intersection points be will be in this object's coordinate space.
If |
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 |
---|---|
cir | An |
relativeTo | The intersection points be will be in this object's coordinate space.
If |
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 |
---|---|
pol2 | A second |
relativeTo | The intersection points be will be in this object's coordinate space.
If |
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 |
---|---|
circle | An |
Returns:
An array containing the intersection points.