raycasting mouse algorithm