Be the first to rate this file! 20 Downloads (last 30 days) File Size: 143.45 KB File ID: #33073
image thumbnail

Triangle/Ray Intersection

by Jaroslaw Tuszynski

 

29 Sep 2011 (Updated 07 Oct 2011)

Fast vectorized triangle/ray intersection algorithm

| Watch this File

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 or 3xN format):
   orig : ray's origin
   dir : ray's direction
   vert0, vert1, vert2: vertices of the triangle
   options: aditional customization options
     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

The author wishes to acknowledge the following in the creation of this submission:
Ray/Triangle Intersection

MATLAB release MATLAB 7.12 (2011a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
28 Feb 2012 Anton Semechko

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

Please login to add a comment or rating.
Updates
07 Oct 2011

Improvements to border handling

Tag Activity for this File
Tag Applied By Date/Time
computer graphics Jaroslaw Tuszynski 30 Sep 2011 11:32:35
intersection Jaroslaw Tuszynski 30 Sep 2011 11:32:35
ray Jaroslaw Tuszynski 30 Sep 2011 11:32:35
ray tracing Jaroslaw Tuszynski 30 Sep 2011 11:32:35
rendering Jaroslaw Tuszynski 30 Sep 2011 11:32:35
triangle Jaroslaw Tuszynski 30 Sep 2011 11:32:35

Contact us at files@mathworks.com