compartmentalize the raycasting logic into a line class