Geometry.IntersectTri Method |
Language: |
Computes the intersection of a ray and a triangle.
Visual Basic Public Shared Function IntersectTri( _
ByVal zero As Vector3, _
ByVal one As Vector3, _
ByVal two As Vector3, _
ByVal rayPos As Vector3, _
ByVal rayDir As Vector3, _
ByRef hitLocation As IntersectInformation _
) As BooleanC# public static bool IntersectTri(
Vector3 zero,
Vector3 one,
Vector3 two,
Vector3 rayPos,
Vector3 rayDir,
out IntersectInformation hitLocation
);C++ public:
static bool IntersectTri(
Vector3 zero,
Vector3 one,
Vector3 two,
Vector3 rayPos,
Vector3 rayDir,
[Out] IntersectInformation% hitLocation
);JScript public static function IntersectTri(
zero : Vector3,
one : Vector3,
two : Vector3,
rayPos : Vector3,
rayDir : Vector3,
hitLocation : IntersectInformation
) : boolean;
zero Microsoft.DirectX.Vector3
A Vector3 structure that describes the first triangle vertex position.one Microsoft.DirectX.Vector3
A Vector3 structure that describes the second triangle vertex position.two Microsoft.DirectX.Vector3
A Vector3 structure that describes the third triangle vertex position.rayPos Microsoft.DirectX.Vector3
A Vector3 structure that specifies the position of the ray.rayDir Microsoft.DirectX.Vector3
A Vector3 structure that specifies the direction of the ray.hitLocation Microsoft.DirectX.Direct3D.IntersectInformation
An IntersectInformation structure that indicates the coordinates at which the ray intersects with the triangle.
System.Boolean
Value that is true if the ray intersects the area of the triangle, or false if it does not.
The IntersectTri method provides a way to understand points in and around a triangle, regardless of its location. This function returns the resulting point by using the following equation:
V1 + U(V2-V1) + V(V3-V1)Any point in the plane V1V2V3 can be represented by the barycentric coordinate (U,V). The U parameter controls how much V2 gets weighted into the result, while the V parameter controls how much V3 gets weighted into the result. Lastly, 1-U-V controls how much V1 gets weighted into the result.
Barycentric coordinates are a form of general coordinates. In this context, using barycentric coordinates represents a change in coordinate systems. What holds true for Cartesian coordinates holds true for barycentric coordinates.
Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center