Code covered by the BSD License

### Highlights fromTriangle/Ray Intersection

Be the first to rate this file! 37 Downloads (last 30 days) File Size: 166 KB File ID: #33073

# Triangle/Ray Intersection

29 Sep 2011 (Updated 21 Mar 2013)

Fast vectorized triangle/ray intersection algorithm

File Information
Description

Ray/triangle intersection using the algorithm proposed by MÃ¶ller and
Trumbore (1997), implemented as highly vectorized MATLAB code.

Input (all arrays in in Nx3, where N is number of vertices or rays):
orig : ray's origin
dir : ray's direction
vert0, vert1, vert2: vertices of the triangle
options.epsilon (default = 1e-5)
options.triangle - 'one sided' or 'two sided' (default) - how to treat
triangles. In 'one sided' version only intersections in single
direction are counted and intersections with back facing
tringles are ignored
options.ray - 'ray' (default) or 'segment' - how to treat ray as an
infinite line (ray) or as line segment defined by a vector

Output:
Intersect - boolean array of length N
t - distance from the ray origin to the intersection point in |dir|
u,v - barycentric coordinates of the intersection point
units

Acknowledgements

Ray/Triangle Intersection inspired this file.

MATLAB release MATLAB 7.12 (R2011a)
Tags for This File
Everyone's Tags
Tags I've Applied
12 Apr 2013

06 Oct 2012

Re to Anton Semechko: This is a low level function which can be called with one ray and many faces, many faces and one ray or many faces and rays. It is quite simple to apply repmat function to the inputs.

28 Feb 2012

why does the number of rays have to equal the number of faces? that's so inconvenient