Back to class index
OBB[Class Summary]
pos
r
axis
ctor (+1 overload)
SetNegativeInfinity()
SetFrom(aabb) (+6 overloads)
SetFromApproximate(...)
ToPolyhedron()[const]
MinimalEnclosingAABB()[const]
MaximalContainedAABB()[const]
MinimalEnclosingSphere()[const]
MaximalContainedSphere()[const]
Size()[const]
HalfSize()[const]
Diagonal()[const]
HalfDiagonal()[const]
WorldToLocal()[const]
LocalToWorld()[const]
IsFinite()[const]
IsDegenerate()[const]
CenterPoint()[const]
Centroid()[const]
Volume()[const]
SurfaceArea()[const]
PointInside(x,y,z)[const]
Edge(edgeIndex)[const]
CornerPoint(cornerIndex)[const]
PointOnEdge(edgeIndex,u)[const]
FaceCenterPoint(faceIndex)[const]
FacePoint(faceIndex,u,v)[const]
FacePlane(faceIndex)[const]
GetCornerPoints(outPointArray)[const]
GetFacePlanes(outPlaneArray)[const]
RandomPointInside(rng)[const]
RandomPointOnSurface(rng)[const]
RandomPointOnEdge(rng)[const]
RandomCornerPoint(rng)[const]
Translate(offset)
Scale(...) (+1 overload)
Transform(transform) (+3 overloads)
ClosestPoint(point)[const]
Distance(point)[const] (+1 overload)
Contains(point)[const] (+7 overloads)
Intersects(aabb)[const] (+11 overloads)
Enclose(point)
Triangulate(...)[const]
ToEdgeList(outPos)[const]
ExtremePointsAlongDirection(...)[static]
PCAEnclosingOBB(...)[static]
NumVerticesInTriangulation(...)[static]
NumVerticesInEdgeList()[static]

OBB::Intersects

Syntax

bool OBB::Intersects(const AABB &aabb) const; [4 lines of code]
bool OBB::Intersects(const OBB &obb, float epsilon=1e-3f) const; [99 lines of code]
bool OBB::Intersects(const Plane &plane) const; [10 lines of code]
bool OBB::Intersects(const Ray &ray, float *dNear, float *dFar) const; [6 lines of code]
bool OBB::Intersects(const Line &line, float *dNear, float *dFar) const; [6 lines of code]
bool OBB::Intersects(const LineSegment &lineSegment, float *dNear, float *dFar) const; [6 lines of code]
bool OBB::Intersects(const Sphere &sphere, float3 *closestPointOnOBB) const; [11 lines of code]
bool OBB::Intersects(const Capsule &capsule) const; [4 lines of code]
bool OBB::Intersects(const Triangle &triangle) const; [6 lines of code]
bool OBB::Intersects(const Polygon &polygon) const; [4 lines of code]
bool OBB::Intersects(const Frustum &frustum) const; [4 lines of code]
bool OBB::Intersects(const Polyhedron &polyhedron) const; [4 lines of code]

Tests whether this OBB and the given object intersect.

Both objects are treated as "solid", meaning that if one of the objects is fully contained inside another, this function still returns true. (e.g. in case a line segment is contained inside this OBB, or this OBB is contained inside a Sphere, etc.) The first parameter of this function specifies the other object to test against.

The OBB-OBB intersection test is from Christer Ericson's book Real-Time Collision Detection, p.

101-106. See http://realtimecollisiondetection.net/

The implementation of OBB-Plane intersection test follows Christer Ericson's Real-Time Collision Detection, p. 163.

The implementation of the OBB-Sphere intersection test follows Christer Ericson's Real-Time Collision Detection, p. 166.

Parameters

floatepsilonThe OBB-OBB test utilizes a SAT test to detect the intersection. A robust implementation requires an epsilon threshold to test that the used axes are not degenerate.float *dNear [out]If specified, receives the parametric distance along the line denoting where the line entered the OBB. This pointer may be null.float *dFar [out]If specified, receives the parametric distance along the line denoting where the line exited the OBB. This pointer may be null.float3 *closestPointOnOBB [out]If specified, receives the closest point on this OBB To the given sphere. This pointer may be null.

Performance

bool OBB::Intersects(const AABB &aabb) const

0.082μsecs/call ≈ 12.18M calls/second ≈ 202.99k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

bool OBB::Intersects(const OBB &obb, float epsilon=1e-3f) const

0.074μsecs/call ≈ 13.53M calls/second ≈ 225.55k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

bool OBB::Intersects(const Plane &plane) const

16.421nsecs/call ≈ 60.9M calls/second ≈ 1.01M calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

bool OBB::Intersects(const Ray &ray, float *dNear, float *dFar) const

0.082μsecs/call ≈ 12.18M calls/second ≈ 202.99k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

bool OBB::Intersects(const Line &line, float *dNear, float *dFar) const

0.086μsecs/call ≈ 11.6M calls/second ≈ 193.33k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

bool OBB::Intersects(const LineSegment &lineSegment, float *dNear, float *dFar) const

0.131μsecs/call ≈ 7.61M calls/second ≈ 126.87k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

bool OBB::Intersects(const Sphere &sphere, float3 *closestPointOnOBB) const

36.947nsecs/call ≈ 27.07M calls/second ≈ 451.09k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

bool OBB::Intersects(const Capsule &capsule) const

25.572μsecs/call ≈ 39.11k calls/second ≈ 651.76 calls/frame (@ 60fps).
This function allocates 4612 bytes (235 blocks) of temporary work memory.

bool OBB::Intersects(const Triangle &triangle) const

0.111μsecs/call ≈ 9.02M calls/second ≈ 150.36k calls/frame (@ 60fps).
This function does not perform dynamic memory allocation.

bool OBB::Intersects(const Polygon &polygon) const

107.03μsecs/call ≈ 9.34k calls/second ≈ 155.72 calls/frame (@ 60fps).
This function allocates 4440 bytes (268 blocks) of temporary work memory.

bool OBB::Intersects(const Frustum &frustum) const

1.26msecs/call ≈ 795.83 calls/second ≈ 13.26 calls/frame (@ 60fps).
This function allocates 39016 bytes (1446 blocks) of temporary work memory.

bool OBB::Intersects(const Polyhedron &polyhedron) const

17.078μsecs/call ≈ 58.56k calls/second ≈ 975.93 calls/frame (@ 60fps).
This function allocates 3460 bytes (155 blocks) of temporary work memory.

See Also

Contains(), Distance(), ClosestPoint().

Work in progress:

Todo: in bool OBB::Intersects(const AABB &aabb) const:
Add Intersects(Circle/Disc).

Leave a Comment

Name:
Comments:
Captcha:captcha image Type in the black symbols:
Back to class index