A ray tracing algorithm