Support Forum G3D Web Page |
Collision detection primitives and tools for building higher order collision detection schemes.
More...
Static Public Member Functions | |
static Vector3 | bounceDirection (const class Sphere &sphere, const Vector3 &velocity, const float collisionTime, const Vector3 &collisionLocation, const Vector3 &collisionNormal) |
Finds the direction of bounce that a sphere would have when it intersects an object with the given time of collision, the collision location and the collision normal. More... | |
static Vector3 | closestPointOnLineSegment (const Vector3 &v0, const Vector3 &v1, const Vector3 &point) |
Finds the closest point on a line segment to a given point. More... | |
static Vector3 | closestPointOnLineSegment (const Vector3 &v0, const Vector3 &v1, const Vector3 &edgeDirection, float edgeLength, const Vector3 &point) |
Finds the closest point on a line segment to a given point. More... | |
static Vector3 | closestPointOnTrianglePerimeter (const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &point) |
Finds the closest point on the perimeter of the triangle to an external point; given a triangle defined by three points v0, v1, & v2, and the external point. More... | |
static Vector3 | closestPointOnTrianglePerimeter (const Vector3 v[3], const Vector3 edgeDirection[3], const float edgeLength[3], const Vector3 &point, int &edgeIndex) |
Finds the closest point on the perimeter of the triangle to an external point; given a triangle defined by the array of points v, its edge directions and their lengths, as well as the external point. More... | |
static void | closestPointsBetweenLineAndLine (const Line &line1, const Line &line2, Vector3 &closest1, Vector3 &closest2) |
Calculates the closest points on two lines with each other. More... | |
static Vector3 | closestPointToRectangle (const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &point) |
Finds the closest point in the rectangle to an external point; Given a rectangle defined by four points v0, v1, v2, & v3, and the external point. More... | |
static Vector3 | closestPointToRectanglePerimeter (const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &point) |
Finds the closest point on the perimeter of the rectangle to an external point; given a rectangle defined by four points v0, v1, v2, & v3, and the external point. More... | |
static bool | collisionLocationForMovingPointFixedAABox (const Vector3 &point, const Vector3 &velocity, const class AABox &box, Vector3 &outLocation, bool &inside=ignoreBool, Vector3 &normal=ignore) |
Calculates time between the intersection of a moving point and a fixed Axis-Aligned Box (AABox). More... | |
static float | collisionTimeForMovingPointFixedAABox (const Vector3 &point, const Vector3 &velocity, const class AABox &box, Vector3 &outLocation, bool &inside=ignoreBool, Vector3 &outNormal=ignore) |
If the ray origin is inside the box, returns inf() but inside is set to true. More... | |
static float | collisionTimeForMovingPointFixedBox (const Vector3 &point, const Vector3 &velocity, const class Box &box, Vector3 &outLocation, Vector3 &outNormal=ignore) |
Calculates time between the intersection of a moving point and a fixed box. More... | |
static float | collisionTimeForMovingPointFixedCapsule (const Vector3 &point, const Vector3 &velocity, const class Capsule &capsule, Vector3 &outLocation, Vector3 &outNormal=ignore) |
Calculates time between the intersection of a moving point and a fixed capsule. More... | |
static float | collisionTimeForMovingPointFixedPlane (const Vector3 &point, const Vector3 &velocity, const class Plane &plane, Vector3 &outLocation, Vector3 &outNormal=ignore) |
Calculates time between the intersection of a moving point and a fixed plane. More... | |
static float | collisionTimeForMovingPointFixedRectangle (const Vector3 &point, const Vector3 &velocity, const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, Vector3 &outLocation, Vector3 &outNormal=ignore) |
Calculates time between the intersection of a moving point and a fixed rectangle defined by the points v0, v1, v2, & v3. More... | |
static float | collisionTimeForMovingPointFixedSphere (const Vector3 &point, const Vector3 &velocity, const class Sphere &sphere, Vector3 &outLocation, Vector3 &outNormal=ignore, bool solid=false) |
Calculates time between the intersection of a moving point and a fixed sphere. More... | |
static float | collisionTimeForMovingPointFixedTriangle (const Vector3 &orig, const Vector3 &dir, const Vector3 &v0, const Vector3 &v1, const Vector3 &v2) |
Calculates time between the intersection of a moving point and a fixed triangle. More... | |
static float | collisionTimeForMovingPointFixedTriangle (const Vector3 &orig, const Vector3 &dir, const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, Vector3 &location) |
Calculates time between the intersection of a moving point and a fixed triangle. More... | |
static float | collisionTimeForMovingPointFixedTriangle (const Vector3 &orig, const Vector3 &dir, const Triangle &tri, Vector3 &location=ignore, Vector3 &normal=ignore) |
Calculates time between the intersection of a moving point and a fixed triangle. More... | |
static float | collisionTimeForMovingPointFixedTriangle (const Vector3 &orig, const Vector3 &dir, const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, Vector3 &location, Vector3 &normal) |
Calculates time between the intersection of a moving point and a fixed triangle. More... | |
static float | collisionTimeForMovingSphereFixedBox (const class Sphere &sphere, const Vector3 &velocity, const class Box &box, Vector3 &outLocation, Vector3 &outNormal=ignore) |
Calculates time between the intersection of a moving sphere and a fixed box. More... | |
static float | collisionTimeForMovingSphereFixedCapsule (const class Sphere &sphere, const Vector3 &velocity, const class Capsule &capsule, Vector3 &outLocation, Vector3 &outNormal=ignore) |
Calculates time between the intersection of a moving sphere and a fixed capsule. More... | |
static float | collisionTimeForMovingSphereFixedPlane (const class Sphere &sphere, const Vector3 &velocity, const class Plane &plane, Vector3 &outLocation, Vector3 &outNormal=ignore) |
Calculates time between the intersection of a moving sphere and a fixed triangle. More... | |
static float | collisionTimeForMovingSphereFixedRectangle (const class Sphere &sphere, const Vector3 &velocity, const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, Vector3 &outLocation, Vector3 &outNormal=ignore) |
Calculates time between the intersection of a moving sphere and a fixed rectangle defined by the points v0, v1, v2, & v3. More... | |
static float | collisionTimeForMovingSphereFixedSphere (const Sphere &sphere, const Vector3 &velocity, const Sphere &fixedSphere, Vector3 &outLocation, Vector3 &outNormal=ignore) |
Calculates time between the intersection of a moving sphere and a fixed sphere. More... | |
static float | collisionTimeForMovingSphereFixedTriangle (const class Sphere &sphere, const Vector3 &velocity, const Triangle &triangle, Vector3 &outLocation, float b[3]=(float *)&ignore, bool twoSided=false) |
Calculates time between the intersection of a moving sphere and a fixed triangle. More... | |
static bool | conservativeBoxBoxTest (const Vector3 &a, const Vector3 &b, const Vector3 &D) |
Performs a simple bounding sphere check between two boxes to determine whether these boxes could possibly intersect. More... | |
static void | fillSolidBoxSolidBoxInfo (const Box &box1, const Box &box2, Vector3 &a, Vector3 &b, Vector3 &D, double *c, double *ca, double *ad, double *bd) |
Creates a set of standard information about two boxes in order to solve for their collision. More... | |
static bool | fixedSolidBoxIntersectsFixedSolidBox (const Box &box1, const Box &box2, const int lastSeparatingAxis=-1) |
Determines whether two fixed solid boxes intersect. More... | |
static bool | fixedSolidBoxIntersectsFixedTriangle (const AABox &box, const Triangle &triangle) |
static bool | fixedSolidSphereIntersectsFixedSolidBox (const Sphere &sphere, const Box &box) |
Tests for the intersection of a fixed sphere and a fixed box. More... | |
static bool | fixedSolidSphereIntersectsFixedSolidSphere (const Sphere &sphere1, const Sphere &sphere2) |
Tests for the intersection of two fixed spheres. More... | |
static bool | fixedSolidSphereIntersectsFixedTriangle (const Sphere &sphere, const Triangle &triangle) |
static bool | isPointInsideRectangle (const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector3 &normal, const Vector3 &point) |
Tests whether a point is inside a rectangle defined by the vertexes v0, v1, v2, & v3, and the rectangle's plane normal. More... | |
static bool | isPointInsideTriangle (const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &normal, const Vector3 &point, float b[3], Vector3::Axis primaryAxis=Vector3::DETECT_AXIS) |
Tests whether a point is contained within the triangle defined by v0, v1, and v2 and its plane's normal. More... | |
static bool | isPointInsideTriangle (const Vector3 &v0, const Vector3 &v1, const Vector3 &v2, const Vector3 &normal, const Vector3 &point, Vector3::Axis primaryAxis=Vector3::DETECT_AXIS) |
static bool | movingSpherePassesThroughFixedBox (const Sphere &sphere, const Vector3 &velocity, const Box &box, double timeLimit=inf()) |
Tests for the intersection of a moving sphere and a fixed box in a given time limit. More... | |
static bool | movingSpherePassesThroughFixedSphere (const Sphere &sphere, const Vector3 &velocity, const Sphere &fixedSphere, double timeLimit=inf()) |
Tests for the intersection of a moving sphere and a fixed sphere in a given time limit. More... | |
static bool | parallelAxisForSolidBoxSolidBox (const double *ca, const double epsilon, int &axis1, int &axis2) |
Tests whether two boxes have axes that are parallel to each other. More... | |
static float | penetrationDepthForFixedBoxFixedBox (const Box &box1, const Box &box2, Array< Vector3 > &contactPoints, Array< Vector3 > &contactNormals, const int lastSeparatingAxis=-1) |
Calculates the depth of penetration between two fixed boxes. More... | |
static float | penetrationDepthForFixedBoxFixedPlane (const Box &box, const Plane &plane, Array< Vector3 > &contactPoints, Array< Vector3 > &contactNormals=ignoreArray) |
Calculates the depth of penetration between a fixed box and a fixed plane as well as the vertexes of the box that penetrate the plane and the plane normals at those intersections. More... | |
static float | penetrationDepthForFixedSphereFixedBox (const Sphere &sphere, const Box &box, Array< Vector3 > &contactPoints, Array< Vector3 > &contactNormals=ignoreArray) |
Calculates the depth of penetration between a fixed sphere and a fixed box as well as the deepest point of the sphere that penetrates the box and the normal at that intersection. More... | |
static float | penetrationDepthForFixedSphereFixedPlane (const Sphere &sphereA, const class Plane &planeB, Array< Vector3 > &contactPoints, Array< Vector3 > &contactNormals=ignoreArray) |
Calculates the depth of penetration between a Fixed Sphere and a Fixed Plane as well as the deepest point of the sphere that penetrates the plane and the plane normal at that intersection. More... | |
static float | penetrationDepthForFixedSphereFixedSphere (const class Sphere &sphereA, const Sphere &sphereB, Array< Vector3 > &contactPoints, Array< Vector3 > &contactNormals=ignoreArray) |
Calculates the depth of penetration between two fixed spheres as well as the deepest point of Sphere A that penetrates Sphere B. More... | |
static float | projectedDistanceForSolidBoxSolidBox (const int separatingAxisIndex, const Vector3 &a, const Vector3 &b, const Vector3 &D, const double *c, const double *ca, const double *ad, const double *bd) |
Calculates the projected distance between the two boxes along the specified separating axis, negative distances correspond to an overlap along that separating axis. More... | |
static bool | rayAABox (const Ray &ray, const Vector3 &invDir, const AABox &box, const Vector3 &boxCenter, float boundingRadiusSquared, Vector3 &location, bool &inside) |
Calculates intersection of a ray and a static Axis-Aligned Box (AABox). More... | |
static Vector3 | separatingAxisForSolidBoxSolidBox (const int separatingAxisIndex, const Box &box1, const Box &box2) |
Converts an index [0, 15] to the corresponding separating axis. More... | |
static Vector3 | slideDirection (const class Sphere &sphere, const Vector3 &velocity, const float collisionTime, const Vector3 &collisionLocation) |
Finds the direction of slide given a moving sphere, its velocity, the time of collision and the collision location. More... | |
Collision detection primitives and tools for building higher order collision detection schemes.
These routines provide moving and static collision detection. Moving collision detection allows the calculation of collisions that occur during a period of time – as opposed to the intersection of two static bodies.
Moving collision detection routines detect collisions between only static primitives and moving spheres or points. Since the reference frame can be user defined, these functions can be used to detect the collision between two moving bodies by subtracting the velocity vector of one object from the velocity vector of the sphere or point the detection is to occur with. This unified velocity vector will act as if both objects are moving simultaneously.
Collisions are detected for single-sided objects only. That is, no collision is detected when leaving a primitive or passing through a plane or triangle opposite the normal... except for the point-sphere calculation or when otherwise noted.
For a sphere, the collision location returned is the point in world space where the surface of the sphere and the fixed object meet. It is not the position of the center of the sphere at the time of the collision.
The collision normal returned is the surface normal to the fixed object at the collision location.
Static Collision Detection: (Neither object is moving)
Point3 | LineSegment | Ray * | Line | Plane | Triangle | Sphere | Cylinder | Capsule | AABox | Box | |
Point3 | P3::== V3::fuzzy distance | ||||||||||
LineSegment | LS::closestPoint LS::distance CD | ||||||||||
Ray * | Ray::closestPoint Ray::distance | ||||||||||
Line | Line::closestPoint Line::distance | CD | |||||||||
Plane | |||||||||||
Triangle | |||||||||||
Sphere | Sphere::contains | CD , R::time | CD | CD | |||||||
Cylinder | Cylinder::contains | ||||||||||
Capsule | Capsule::contains | CD | |||||||||
AABox | AABox::contains | CD | |||||||||
Box | Box::contains | (treat as Ray) | CD | (treat as Ray) | CD | CD | CD | None (use OPCODE) | CD | CD | CD |
Moving Collision Detection:
* Note: Moving collision detection against certain primitives is equivalent to static collision detection against a bigger primitive. Ray, Line Segment == moving Point''; Capsule ==
moving Sphere''; Plane == `‘moving Line’'
|
static |
Finds the direction of bounce that a sphere would have when it intersects an object with the given time of collision, the collision location and the collision normal.
sphere | Moving sphere. |
velocity | Sphere's velocity. |
collisionTime | Time of collision. |
collisionLocation | Collision location. |
collisionNormal | Surface collision normal. |
|
static |
Finds the closest point on a line segment to a given point.
v0 | line vertex 1. |
v1 | line vertex 2. |
point | External point. |
point
on the line segment.
|
static |
Finds the closest point on a line segment to a given point.
v0 | line vertex 0. |
v1 | line vertex 1. |
edgeDirection | The direction of the segment (unit length). |
edgeLength | The length of the segment. |
point | External point. |
point
on the line segment.
|
static |
Finds the closest point on the perimeter of the triangle to an external point; given a triangle defined by three points v0, v1, & v2, and the external point.
point
on the perimeter of the triangle.
|
static |
Finds the closest point on the perimeter of the triangle to an external point; given a triangle defined by the array of points v, its edge directions and their lengths, as well as the external point.
v | Triangle vertices. |
point | External point. |
edgeIndex | The point lies on the edge between v[edgeIndex] and v[(edgeIndex + 1) % 3] |
point
on the perimeter of the triangle.
|
static |
Calculates the closest points on two lines with each other.
If the lines are parallel then using the starting point, else calculate the closest point on each line to the other.
|
static |
Finds the closest point in the rectangle to an external point; Given a rectangle defined by four points v0, v1, v2, & v3, and the external point.
v0 | Rectangle vertex 1. |
v1 | Rectangle vertex 2. |
v2 | Rectangle vertex 3 |
v3 | Rectangle vertex 4. |
point | External point. |
|
static |
Finds the closest point on the perimeter of the rectangle to an external point; given a rectangle defined by four points v0, v1, v2, & v3, and the external point.
v0 | Rectangle vertex 1. |
v1 | Rectangle vertex 2. |
v2 | Rectangle vertex 3. |
v3 | Rectangle vertex 4. |
point | External point. |
point
on the perimeter of the rectangle.
|
static |
Calculates time between the intersection of a moving point and a fixed Axis-Aligned Box (AABox).
point | Moving point. |
velocity | Sphere's velocity. |
box | Fixed AAbox. |
outLocation | Location of collision. [Post Condition] |
inside | Does the ray originate inside the box? [Post Condition] |
normal | Box's surface normal to collision [Post Condition] |
Referenced by G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::Node::intersectRay(), and G3D::KDTree< T, BoundsFunc, HashFunc, EqualsFunc >::Node::intersects().
|
static |
If the ray origin is inside the box, returns inf() but inside is set to true.
Beta API
|
static |
Calculates time between the intersection of a moving point and a fixed box.
point | Moving point. |
velocity | Sphere's velocity. |
box | Fixed box. |
outLocation | Position of collision. [Post Condition] |
outNormal | Box's surface normal to collision [Post Condition] |
|
static |
Calculates time between the intersection of a moving point and a fixed capsule.
point | Moving point. |
velocity | Point's velocity. |
capsule | Fixed capsule. |
outLocation | Location of collision. [Post Condition] |
outNormal | Capsule's surface normal to collision [Post Condition] |
|
static |
Calculates time between the intersection of a moving point and a fixed plane.
point | Moving point. |
velocity | Point's velocity. |
plane | Fixed plane. |
outLocation | Location of collision. [Post Condition] (Infinite vector on no collision) |
outNormal | Plane's surface normal. [Post Condition] |
|
static |
Calculates time between the intersection of a moving point and a fixed rectangle defined by the points v0, v1, v2, & v3.
point | Moving point. |
velocity | Sphere's velocity. |
v0 | Rectangle vertex 1. |
v1 | Rectangle vertex 2. |
v2 | Rectangle vertex 3 |
v3 | Rectangle vertex 4. |
outLocation | Location of collision [Post Condition] |
outNormal | Rectangle's surface normal. [Post Condition] |
|
static |
Calculates time between the intersection of a moving point and a fixed sphere.
point | Moving point. |
velocity | Point's velocity. |
sphere | Fixed Sphere. |
outLocation | Location of collision. [Post Condition] |
outNormal | Sphere's surface normal to collision [Post Condition] |
solid | If true, rays inside the sphere immediately intersect (good for collision detection). If false, they hit the opposite side of the sphere (good for ray tracing). |
|
inlinestatic |
Calculates time between the intersection of a moving point and a fixed triangle.
orig | Moving point. |
dir | Point's velocity. |
v0 | Triangle vertex 1. |
v1 | Triangle vertex 2. |
v2 | Triangle vertex 3 |
Referenced by collisionTimeForMovingPointFixedTriangle().
|
inlinestatic |
Calculates time between the intersection of a moving point and a fixed triangle.
orig | Moving point. |
dir | Point's velocity. |
v0 | Triangle vertex 1. |
v1 | Triangle vertex 2. |
v2 | Triangle vertex 3 |
location | Location of collision. [Post Condition] (Infinite vector on no collision) |
|
inlinestatic |
Calculates time between the intersection of a moving point and a fixed triangle.
orig | Moving point. |
dir | Point's velocity. |
tri | Fixed triangle. |
location | Location of collision. [Post Condition] (Infinite vector on no collision) |
normal | Triangle's surface normal. [Post Condition] |
|
inlinestatic |
Calculates time between the intersection of a moving point and a fixed triangle.
orig | Moving point. |
dir | Point's velocity. |
v0 | Triangle vertex 1. |
v1 | Triangle vertex 2. |
v2 | Triangle vertex 3 |
location | Location of collision. [Post Condition] (Infinite vector on no collision) |
normal | Triangle's surface normal. [Post Condition] |
|
static |
Calculates time between the intersection of a moving sphere and a fixed box.
sphere | Moving sphere. |
velocity | Sphere's velocity. |
box | Fixed box. |
outLocation | Location of collision – not center position of sphere at the collision time. [Post Condition] |
outNormal | Box's surface normal to collision [Post Condition] |
|
static |
Calculates time between the intersection of a moving sphere and a fixed capsule.
sphere | Moving sphere. |
velocity | Sphere's velocity. |
capsule | Fixed capsule. |
outLocation | Location of collision – not center position of sphere at the collision time. [Post Condition] |
outNormal | Capsule's surface normal to the collision [Post Condition] |
|
static |
Calculates time between the intersection of a moving sphere and a fixed triangle.
sphere | Moving sphere. |
velocity | Sphere's velocity. |
plane | Fixed Plane. |
outLocation | Location of collision – not center position of sphere at the collision time. [Post Condition] |
outNormal | Box's surface normal to collision [Post Condition] |
|
static |
Calculates time between the intersection of a moving sphere and a fixed rectangle defined by the points v0, v1, v2, & v3.
sphere | Moving sphere. |
velocity | Sphere's velocity. |
v0 | Rectangle vertex 1. |
v1 | Rectangle vertex 2. |
v2 | Rectangle vertex 3 |
v3 | Rectangle vertex 4. |
outLocation | Location of collision – not center position of sphere at the collision time. [Post Condition] |
outNormal | Box's surface normal to collision [Post Condition] |
|
static |
Calculates time between the intersection of a moving sphere and a fixed sphere.
If they are already interpenetrating, returns 0 and location is the closest point on the surface of the fixed sphere to the center of the moving sphere.
sphere | Moving sphere. |
velocity | Sphere's velocity. |
fixedSphere | Fixed Sphere. |
outLocation | Location of collision – not center position of sphere at the collision time. [Post Condition] |
outNormal | Moving sphere's surface normal to collision [Post Condition] |
|
static |
Calculates time between the intersection of a moving sphere and a fixed triangle.
sphere | The moving sphere. |
velocity | The sphere's velocity. |
triangle | Single-sided fixed triangle. |
outLocation | Location of collision, if collision occurs – not center position of sphere at the collision time. If there is interpenetration at the start, this point may be inside the sphere. |
b | Barycentric coordinates. These are not valid unless collision occurs. |
|
static |
Performs a simple bounding sphere check between two boxes to determine whether these boxes could possibly intersect.
This is a very cheap operation (three dot products, two sqrts and a few others). If it returns true, an intersection is possible, but not necessarily guaranteed.
a | Vector from box A's center to an outer vertex |
b | Vector from box B's center to an outer vertex |
D | Distance between the centers of the two boxes |
|
static |
Creates a set of standard information about two boxes in order to solve for their collision.
This information includes a vector to the radius of the bounding sphere for each box, the vector between each boxes' center and a series of dot products between differing important vectors. These dot products include those between the axes of both boxes (signed and unsigned values), and the dot products between all the axes of box1 and the boxes' center vector and box2 and the boxes' center vector.
box1 | Box 1 |
box2 | Box 2 |
a | Box 1's bounding sphere vector |
b | Box 2's bounding sphere vector |
D | Vector between Box 1 and Box 2's center points |
c | Pointer to array of dot products of the axes of Box 1 and Box 2. |
ca | Pointer to array of unsigned dot products of the axes of Box 1 and Box 2. |
ad | Pointer to array of dot products of Box 1 axes and D. |
bd | Pointer to array of dot products of Box 2 axes and D. |
|
static |
Determines whether two fixed solid boxes intersect.
|
static |
|
static |
Tests for the intersection of a fixed sphere and a fixed box.
sphere | Fixed sphere. |
box | Fixed box. |
|
static |
Tests for the intersection of two fixed spheres.
sphere1 | Fixed sphere 1. |
sphere2 | Fixed sphere 2. |
|
static |
|
static |
Tests whether a point is inside a rectangle defined by the vertexes v0, v1, v2, & v3, and the rectangle's plane normal.
v0 | Rectangle vertex 1. |
v1 | Rectangle vertex 2. |
v2 | Rectangle vertex 3. |
v3 | Rectangle vertex 4. |
normal | Normal to rectangle's plane. |
point | The point in question. |
|
static |
Tests whether a point is contained within the triangle defined by v0, v1, and v2 and its plane's normal.
v0 | Triangle vertex 0. |
v1 | Triangle vertex 1. |
v2 | Triangle vertex 2. |
normal | Normal to triangle's plane. |
point | The point in question. |
primaryAxis | Primary axis of triangle. This will be detected if not given. This parameter is provided as an optimization. |
b | Barycentric coordinates; b[i] is the weight on v[i] |
Referenced by isPointInsideTriangle().
|
inlinestatic |
|
static |
Tests for the intersection of a moving sphere and a fixed box in a given time limit.
sphere | Moving sphere. |
velocity | Velocity of moving sphere. |
box | Fixed box. |
timeLimit | Time limit for intersection test. |
|
static |
Tests for the intersection of a moving sphere and a fixed sphere in a given time limit.
sphere | Moving sphere. |
velocity | Velocity of moving sphere. |
fixedSphere | Fixed sphere. |
timeLimit | Time limit for intersection test. |
|
static |
Tests whether two boxes have axes that are parallel to each other.
If they are, axis1 and axis2 are set to be the parallel axes for both box1 and box2 respectively.
ca | Dot products of each of the boxes axes |
epsilon | Fudge factor (small unit by which the dot products may vary and still be considered zero). |
axis1 | Parallel Axis 1. [Post Condition] |
axis2 | Parallel Axis 2. [Post Condition] |
|
static |
Calculates the depth of penetration between two fixed boxes.
Contact normal faces away from box1 and into box2. If there is contact, only one contact point is returned. The minimally violated separating plane is computed
box1 | Box 1 |
box2 | Box 2 |
contactPoints | Contact point between boxes. [Post Condition] |
contactNormals | Surface normal at contact point. [Post Condition] |
lastSeparatingAxis | Last separating axis. (Used for optimization) |
|
static |
Calculates the depth of penetration between a fixed box and a fixed plane as well as the vertexes of the box that penetrate the plane and the plane normals at those intersections.
box | Fixed Box. |
plane | Fixed Plane. |
contactPoints | Box points that penetrate the plane. [Post Condition] |
contactNormals | Normals at penetration points [Post Condition] |
|
static |
Calculates the depth of penetration between a fixed sphere and a fixed box as well as the deepest point of the sphere that penetrates the box and the normal at that intersection.
The contact point and contact normal vary for each of these situations.
sphere | Fixed Sphere. |
box | Fixed Box. |
contactPoints | Sphere point that penetrates the box. [Post Condition] |
contactNormals | Normal at the penetration point. [Post Condition] |
|
static |
Calculates the depth of penetration between a Fixed Sphere and a Fixed Plane as well as the deepest point of the sphere that penetrates the plane and the plane normal at that intersection.
sphereA | Fixed Sphere. |
planeB | Fixed Plane. |
contactPoints | Sphere point that penetrates the plane. [Post Condition] |
contactNormals | Normal at penetration point. [Post Condition] |
|
static |
Calculates the depth of penetration between two fixed spheres as well as the deepest point of Sphere A that penetrates Sphere B.
The normal returned points away from the object A, although it may represent a perpendicular to either the faces of object B or object A depending on their relative orientations.
sphereA | Fixed Sphere A. |
sphereB | Fixed Sphere B. |
contactPoints | Sphere A's deepest point that penetrates Sphere B. [Post Condition] |
contactNormals | Normal at penetration point. [Post Condition] |
|
static |
Calculates the projected distance between the two boxes along the specified separating axis, negative distances correspond to an overlap along that separating axis.
The distance is not divided by denominator dot(L, L), see penetrationDepthForFixedSphereFixedBox() for more details
separatingAxisIndex | |
a | Box 1's bounding sphere vector |
b | Box 2's bounding sphere vector |
D | Vector between Box 1 and Box 2's center points |
c | Pointer to array of dot products of the axes of Box 1 and Box 2. |
ca | Pointer to array of unsigned dot products of the axes of Box 1 and Box 2. |
ad | Pointer to array of dot products of Box 1 axes and D. |
bd | Pointer to array of dot products of Box 2 axes and D. |
|
static |
Calculates intersection of a ray and a static Axis-Aligned Box (AABox).
invDir | 1/dir |
location | Location of collision. [Post Condition] |
inside | Does the ray originate inside the box? [Post Condition] |
|
static |
Finds the direction of slide given a moving sphere, its velocity, the time of collision and the collision location.
This function works as if the sphere intersects the surface and continues to hug it.
sphere | Moving sphere. |
velocity | Sphere's velocity. |
collisionTime | Time of collision |
collisionLocation | Collision location. |