intersectstriangle

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 1.0, Creation date: 2012-07-13, Last change: 2025-09-14

fundamental fnct for the intersection between a ray and a triangle


Use carefully: The 'intersectstriangle' function has not yet been extensively tested

Description

References see: http://www.lighthouse3d.com/tutorials/maths
MAJOR CHANGE IN SG-LIB 4.7 because of a clear missing intersection. Threshold is now applied to all decisions


See Also: crossingfacets2VLFL , cross2F , VLprojection , crosspointVLFL , crosspointsVLFLofT , crosspointVLFL2

Example Illustration

 missing image of intersectstriangle(p,d,v0,v1,v2)

Syntax

[b,t]=intersectstriangle(p,d,v0,v1,v2)

Input Parameter

p: Point of line
d: Direction of line
v0: Vertex 0
v1: Vertex 1
v2: Vertex 2

Output Parameter

b: if t>0 and intersecting point exists
t: intersecting point is p+t*d

Examples


[a,b]=intersectstriangle([5 5 -10],[0 0 1],[0 0 0],[10 0 0],[10 10 0])




Copyright 2012-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Last html export of this page out of FM database by TL: 2025-09-21