Better parallel/perpendicular calculation for rays