Code

Here is some public domain code that I have developed:
  • Ray-Triangle Intersection
    Developed with Ben Trumbore from Cornell University. The source is here.
    I also have some extra optimizations for this and some extra statistics for different CPUs.
  • Triange-Triangle Overlap Test [Updated 2001-06-20]
    The original source code is here. I have optimized (in that I replaced the divisions with some multiplications - from a suggestion by Dave Eberly) that code since then. New (faster) code is here. If you want the line of intersection as well, the get this code.
  • Triangle-Box Overlap Test [Updated 2004-08-25]
    Old code is here.
    New, faster code is here. It's not noticably faster on a 1333 MHz PC, but it's about 15% faster on a SUN 333MHz.
    Bug-fixed code This is the code you should get. It correctly reports intersections for triangles completely in a box plane. Bug fix by Nick Pelling: thanks!
  • Rotation from one vector to another
    Source code.
Back