the code you showed means... it assume(approximate) curved screen(part of cylinder). the view point is the center of the cylinder. "rayangle" is the angle of the casting ray. "cameraangle" is the angle to the center of the screen. "fov" is the angle of the arc streched by the screen "horizon" is the number of the pixels of the screen. it's all.