Ray-aware line segment intersection check.