Back to class index
Triangle[Class Summary]
a
b
c
ctor (+1 overload)
Translate(offset)
Transform(transform) (+3 overloads)
BarycentricUVW(point)[const]
BarycentricUV(point)[const]
Point(uvw)[const] (+3 overloads)
Centroid()[const]
CenterPoint()[const]
Area()[const]
Perimeter()[const]
VertexArrayPtr() (+1 overload)
Vertex(i)[const]
CornerPoint(i)[const]
Edge(i)[const]
PlaneCCW()[const]
PlaneCW()[const]
NormalCCW()[const]
NormalCW()[const]
UnnormalizedNormalCCW()[const]
UnnormalizedNormalCW()[const]
AnyPointFast()[const]
ExtremePoint(direction)[const] (+1 overload)
ToPolygon()[const]
ToPolyhedron()[const]
BoundingAABB()[const]
IsFinite()[const]
IsDegenerate(epsilon)[const]
Contains(...)[const] (+2 overloads)
Distance(point)[const] (+2 overloads)
DistanceSq(point)[const]
Intersects(...)[const] (+12 overloads)
ProjectToAxis(axis,dMin,dMax)[const]
UniqueFaceNormals(out)[const]
UniqueEdgeDirections(out)[const]
ClosestPoint(point)[const] (+3 overloads)
ClosestPointToTriangleEdge(...)[const] (+1 overload)
RandomPointInside(rng)[const]
RandomVertex(rng)[const]
RandomPointOnEdge(rng)[const]
ToString()[const]
SerializeToString()[const]
SerializeToCodeString()[const]
Equals(rhs,epsilon)[const]
BitEquals(other)[const]
NumFaces()[static]
NumEdges()[static]
NumVertices()[static]
BarycentricInsideTriangle(uvw)[static]
Area2D(p1,p2,p3)[static]
SignedArea(point,a,b,c)[static]
IsDegenerate(p1,p2,p3,epsilon)[static]
IntersectLineTri(...)[static]
FromString(str,outEndStr)[static] (+1 overload)

Triangle::Intersects

Syntax

bool Triangle::Intersects(const LineSegment &lineSegment, float *d=0, float4 *intersectionPoint=0) const; [16 lines of code]
bool Triangle::Intersects(const Line &line, float *d=0, float4 *intersectionPoint=0) const; [13 lines of code]
bool Triangle::Intersects(const Ray &ray, float *d=0, float4 *intersectionPoint=0) const; [13 lines of code]
bool Triangle::Intersects(const Plane &plane) const; [4 lines of code]
bool Triangle::Intersects(const Sphere &sphere, float4 *closestPointOnTriangle) const; [9 lines of code]
bool Triangle::Intersects(const Sphere &sphere) const; [4 lines of code]
bool Triangle::Intersects(const Triangle &triangle, LineSegment *outLine=0) const; [88 lines of code]
bool Triangle::Intersects(const AABB &aabb) const; [202 lines of code]
bool Triangle::Intersects(const OBB &obb) const; [4 lines of code]
bool Triangle::Intersects(const Polygon &polygon) const; [4 lines of code]
bool Triangle::Intersects(const Frustum &frustum) const; [4 lines of code]
bool Triangle::Intersects(const Polyhedron &polyhedron) const; [4 lines of code]
bool Triangle::Intersects(const Capsule &capsule) const; [4 lines of code]

Tests whether this triangle 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 triangle, or this triangle is contained inside a sphere, etc.)

The Triangle-Line/LineSegment/Ray intersection tests are based on Mller-Trumbore method: "T. Möller, B. Trumbore. Fast, Minimum Storage Ray/Triangle Intersection. 2005." http://jgt.akpeters.com/papers/MollerTrumbore97/.

For Triangle-Sphere intersection code, see Christer Ericson's Real-Time Collision Detection, p.167.

The Triangle-Triangle test implementation is based on pseudo-code from Tomas Mller's "A Fast Triangle-Triangle Intersection Test": http://jgt.akpeters.com/papers/Moller97/. See also Christer Ericson's Real-Time Collision Detection, p. 172.

The AABB-Triangle test implementation is based on the pseudo-code in Christer Ericson's Real-Time Collision Detection, pp. 169-172. It is practically a standard SAT test.

Parameters

float *d [out]If specified, this parameter will receive the parametric distance of the intersection point along the line object. Use the GetPoint(d) function of the line class to get the actual point of intersection. This pointer may be null.float4 *intersectionPoint [out]If specified, receives the actual point of intersection. This pointer may be null.float4 *closestPointOnTriangle [out]If specified, receives the point of intersection between the Sphere and this Triangle. Even if no intersection occurred, this parameter will receive the closest point on the Triangle to the Sphere. This pointer may be null.LineSegment *outLine [out]If specified, receives the line segment of the common points shared by the two intersecting triangles. If the two triangles do not intersect, this pointer is not written to. This pointer may be null.

Return Value

True if an intersection occurs or one of the objects is contained inside the other, false otherwise.

See Also

Contains(), Distance(), ClosestPoint(), LineSegment::GetPoint().