raytracing routine debugged part 1 of 2