File Exchange

image thumbnail

A fast voxel traversal algorithm for ray tracing

version 1.0.0.0 (185 KB) by Jesús P. Mena-Chalco
A fast and simple voxel traversal algorithm through a 3D space partition (uniform grid)

12 Downloads

Updated 04 Mar 2010

View License

A fast and simple voxel traversal algorithm through a 3D space partition (grid) proposed by J. Amanatides and A. Woo (1987).

Author:
Jesús P. Mena-Chalco.

References:
[1] "A fast voxel traversal algorithm for ray tracing"
J. Amanatides and A. Woo.
Eurographics, 87(3), 1987

[2] Other implementations of this algorithm are available from the Web:
- http://www.ray-tracing.ru/articles182.html
- http://www.clockworkcoders.com/oglsl/rt/gpurt3.htm
- http://www.devmaster.net/articles/raytracing_series/part4.php

Comments and Ratings (3)

alex

Hi this algorithm works for doubly curved lens??

it works !!

Vincent

Hi,

had to make a few adoptions to make it work for axes parallel rays:

1) In the rayBoxIntersection.m: Following the advice in the paper "An efficient and robust ray-box intersection algorithm" under the point improved code:

divx = 1/direction(1);
if (divx >= 0)
...

instead of

if (direction(1) >= 0)
...

for x,y and z each.

2) In amanatidesWooAlgorithm.m using

if direction(1) == 0
tMaxX = inf;
else
tMaxX = tmin + (voxelMaxX-start(1))/direction(1);
end

instead of

tMaxX = tmin + (voxelMaxX-start(1))/direction(1);

for x,y and z each. Before it calculated -Inf instead of Inf when dividing by zero.

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux