3D grid ray detection

Hi, I'm looking for some ideas for an algorithm that, very broadly, enumerates the 3D cells through which a ray passes (the cells must be in order).
I have the starting position and direction of the ray in 3D co-ordinates. The direction will be given as the X-, Y-, and Z-rotation of the ray, so (for example) I may need to use the tan() function from <cmath> to convert the rotation into a gradient. I don't know.

For clarity, by 'cell' I mean a 3D version of a spreadsheet cell. These cells are cubes, though, unlike the elongated oblongs in a spreadsheet.

The idea behind this is to display a voxel model on the screen - it's just ray casting with voxels instead of triangles. Since the above algorithm would need to run once for every pixel on the screen, I would prefer a speedy algorithm to an elegant one. All thoughts appreciated.
Thanks for your time!

PS. In case you were wondering, this is NOT a piece of coursework, or homework, or any other work; nor is it for a competition. It's just a personal project of mine.
Last edited on
If you want raycasting explained, see http://www.permadi.com/tutorial/raycast/rayc6.html
This is 2D, but in 3D same logic works.
It might not be a great idea though. What exactly is your goal?
Topic archived. No new replies allowed.