public Split splitDiameter()

in commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/AngularInterval.java [498:582]


        public Split<Convex> splitDiameter(final CutAngle splitter) {

            final CutAngle opposite = CutAngles.fromPointAndDirection(
                    splitter.getPoint().antipodal(),
                    !splitter.isPositiveFacing(),
                    splitter.getPrecision());

            if (isFull()) {
                final Convex minus = Convex.of(splitter, opposite);
                final Convex plus = Convex.of(splitter.reverse(), opposite.reverse());

                return new Split<>(minus, plus);
            }

            final CutAngle minBoundary = getMinBoundary();
            final CutAngle maxBoundary = getMaxBoundary();

            final Point1S posPole = Point1S.of(splitter.getPoint().getAzimuth() + Angle.PI_OVER_TWO);

            final int minLoc = minBoundary.getPrecision().compare(Angle.PI_OVER_TWO,
                    posPole.distance(minBoundary.getPoint()));
            final int maxLoc = maxBoundary.getPrecision().compare(Angle.PI_OVER_TWO,
                    posPole.distance(maxBoundary.getPoint()));

            final boolean positiveFacingSplit = splitter.isPositiveFacing();

            // assume a positive orientation of the splitter for region location
            // purposes and adjust later
            Convex pos = null;
            Convex neg = null;

            if (minLoc > 0) {
                // min is on the pos side

                if (maxLoc >= 0) {
                    // max is directly on the splitter or on the pos side
                    pos = this;
                } else {
                    // min is on the pos side and max is on the neg side
                    final CutAngle posCut = positiveFacingSplit ?
                            opposite.reverse() :
                            opposite;
                    pos = Convex.of(minBoundary, posCut);

                    final CutAngle negCut = positiveFacingSplit ?
                            opposite :
                            opposite.reverse();
                    neg = Convex.of(negCut, maxBoundary);
                }
            } else if (minLoc < 0) {
                // min is on the neg side

                if (maxLoc <= 0) {
                    // max is directly on the splitter or on the neg side
                    neg = this;
                } else {
                    // min is on the neg side and max is on the pos side
                    final CutAngle posCut = positiveFacingSplit ?
                            splitter.reverse() :
                            splitter;
                    pos = Convex.of(maxBoundary, posCut);

                    final CutAngle negCut = positiveFacingSplit ?
                            splitter :
                            splitter.reverse();
                    neg = Convex.of(negCut, minBoundary);
                }
            } else {
                // min is directly on the splitter; determine whether it was on the main split
                // point or its antipodal point
                if (splitter.getPoint().distance(minBoundary.getPoint()) < Angle.PI_OVER_TWO) {
                    // on main splitter; interval will be located on pos side of split
                    pos = this;
                } else {
                    // on antipodal point; interval will be located on neg side of split
                    neg = this;
                }
            }

            // adjust for the actual orientation of the splitter
            final Convex minus = positiveFacingSplit ? neg : pos;
            final Convex plus = positiveFacingSplit ? pos : neg;

            return new Split<>(minus, plus);
        }