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::IntersectLineTri

Syntax

float Triangle::IntersectLineTri(const float4 &linePos, const float4 &lineDir, const float4 &v0, const float4 &v1, const float4 &v2, float &u, float &v); [43 lines of code]

A helper function used in line-triangle tests.

Calculates the intersection between a line and a triangle.

The facing is not accounted for, so rays are reported to intersect triangles that are both front and backfacing. According to "T. Möller, B. Trumbore. Fast, Minimum Storage Ray/Triangle Intersection. 2005." http://jgt.akpeters.com/papers/MollerTrumbore97/

Parameters

const float4 &linePosThe starting point of the line. const float4 &lineDirThe direction vector of the line. This does not need to be normalized. const float4 &v0Vertex 0 of the triangle. const float4 &v1Vertex 1 of the triangle. const float4 &v2Vertex 2 of the triangle. float &u [out]The barycentric u coordinate is returned here if an intersection occurred.float &v [out]The barycentric v coordinate is returned here if an intersection occurred.

Return Value

The distance along the ray to the point of intersection, or +inf if no intersection occurred. If no intersection, then u and v and t will contain undefined values. If lineDir was not normalized, then to get the real world-space distance, one must scale the returned value with lineDir.Length(). If the returned value is negative, then the intersection occurs 'behind' the line starting position, with respect to the direction vector lineDir.