in commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Planes.java [839:889]
private PlaneConvexSubset extrudeSideInfinite(final LineConvexSubset lineSubset) {
final Vector2D subLinePt = lineSubset.getLine().getOrigin();
final Vector2D subLineDir = lineSubset.getLine().getDirection();
final Vector3D linePt = basePlane.toSpace(subLinePt);
final Vector3D lineDir = linePt.vectorTo(basePlane.toSpace(subLinePt.add(subLineDir)));
final EmbeddingPlane sidePlane;
if (extrudingOnPlusSide) {
sidePlane = fromPointAndPlaneVectors(linePt, lineDir, extrusionVector, precision);
} else {
sidePlane = fromPointAndPlaneVectors(linePt, extrusionVector, lineDir, precision);
}
final Vector2D sideLineOrigin = sidePlane.toSubspace(linePt);
final Vector2D sideLineDir = sideLineOrigin.vectorTo(sidePlane.toSubspace(linePt.add(lineDir)));
final Vector2D extrudedSideLineOrigin = sidePlane.toSubspace(linePt.add(extrusionVector));
final Vector2D sideExtrusionDir = sidePlane.toSubspace(sidePlane.getOrigin().add(extrusionVector))
.normalize();
// construct a list of lines forming the bounds of the extruded subspace region
final List<Line> lines = new ArrayList<>();
// add the top and bottom lines (original and extruded)
if (extrudingOnPlusSide) {
lines.add(Lines.fromPointAndDirection(sideLineOrigin, sideLineDir, precision));
lines.add(Lines.fromPointAndDirection(extrudedSideLineOrigin, sideLineDir.negate(), precision));
} else {
lines.add(Lines.fromPointAndDirection(sideLineOrigin, sideLineDir.negate(), precision));
lines.add(Lines.fromPointAndDirection(extrudedSideLineOrigin, sideLineDir, precision));
}
// if we have a point on the original line, then connect the two
final Vector2D startPt = lineSubset.getStartPoint();
final Vector2D endPt = lineSubset.getEndPoint();
if (startPt != null) {
lines.add(Lines.fromPointAndDirection(
sidePlane.toSubspace(basePlane.toSpace(startPt)),
extrudingOnPlusSide ? sideExtrusionDir.negate() : sideExtrusionDir,
precision));
} else if (endPt != null) {
lines.add(Lines.fromPointAndDirection(
sidePlane.toSubspace(basePlane.toSpace(endPt)),
extrudingOnPlusSide ? sideExtrusionDir : sideExtrusionDir.negate(),
precision));
}
return subsetFromConvexArea(sidePlane, ConvexArea.fromBounds(lines));
}