From Solid Graphics Wiki

Jump to: navigation, search
Namespace: SKL3D
Member of: (this function is not member of any class)
Include: Skl3DMath.h
Lib (Release): SKL.lib
Lib (Debug): SKL_D.lib

The LineTriangleIntersection function calculates a line's intersection with a triangle.

int LineTriangleIntersection
         const float lStart[ 3 ],
         const float lEnd[ 3 ],
         const float t0[ 3 ],
         const float t1[ 3 ],
         const float t2[ 3 ],
         float s[ 2 ]
int LineTriangleIntersection
         const double lStart[ 3 ],
         const double lEnd[ 3 ],
         const double t0[ 3 ],
         const double t1[ 3 ],
         const double t2[ 3 ],
         double s[ 2 ]


lStart x,y,z coordinates of line's first definition point.
lEnd x,y,z coordinates of line's second definition point.
t0 x,y,z coordinates of the first point defining the triangle.
t1 x,y,z coordinates of the second point defining the triangle.
t2 x,y,z coordinates of the third point defining the triangle.
s if line intersects the triangle the variable pointed by s will contain position of the intersection point on the line. If return value is 2 the variable will contain position of two edge points where the line intersects the triangle. The point position(s) can be then translated to it's (their) coordinates using the LinePositionToPoint function.

Return Value

The function returns 0 if the line and the triangle do not intersect, 1 if the line intersects the triangle in one point, 2 if the line lies in the triangle's plane and intersects it in more than one triangle's edge.

See Also


SolidKit Library Documentation

Personal tools