in commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Segment.java [183:210]
Split<LineConvexSubset> splitOnIntersection(final Line splitter, final Vector2D intersection) {
final Line line = getLine();
final Precision.DoubleEquivalence splitterPrecision = splitter.getPrecision();
final int startCmp = splitterPrecision.compare(splitter.offset(startPoint), 0.0);
final int endCmp = splitterPrecision.compare(splitter.offset(endPoint), 0.0);
if (startCmp == 0 && endCmp == 0) {
// the entire segment is directly on the splitter line
return new Split<>(null, null);
} else if (startCmp < 1 && endCmp < 1) {
// the entire segment is on the minus side
return new Split<>(this, null);
} else if (startCmp > -1 && endCmp > -1) {
// the entire segment is on the plus side
return new Split<>(null, this);
}
// we need to split the line
final Segment startSegment = new Segment(line, startPoint, intersection);
final Segment endSegment = new Segment(line, intersection, endPoint);
final Segment minus = (startCmp > 0) ? endSegment : startSegment;
final Segment plus = (startCmp > 0) ? startSegment : endSegment;
return new Split<>(minus, plus);
}