toRange
Maps the segment a ClosedRange, this is done by extracting either the X coordinates or the Y coordinates of the two endpoints of the segment. getXCoords indicates which pair of coordinates should be extracted (defaults to isHorizontal). This can be useful e.g. to represent portions of axis-aligned segments without creating new ones.