Algorithms for ray tracing