Example usage for org.apache.commons.math3.geometry.partitioning SubHyperplane split

List of usage examples for org.apache.commons.math3.geometry.partitioning SubHyperplane split

Introduction

In this page you can find the example usage for org.apache.commons.math3.geometry.partitioning SubHyperplane split.

Prototype

SplitSubHyperplane<S> split(Hyperplane<S> hyperplane);

Source Link

Document

Split the instance in two parts by an hyperplane.

Usage

From source file:org.orekit.models.earth.tessellation.EllipsoidTessellator.java

/** Check if an arc meets the inside of a zone.
 * <p>/*  w w w .jav  a  2  s.  co m*/
 * This method is heavily based on the Characterization class from
 * Apache Commons Math library, also distributed under the terms
 * of the Apache Software License V2.
 * </p>
 * @param node spherical zone node
 * @param sub arc to characterize
 * @return true if the arc meets the inside of the zone
 */
private boolean recurseMeetInside(final BSPTree<Sphere2D> node, final SubHyperplane<Sphere2D> sub) {

    if (node.getCut() == null) {
        // we have reached a leaf node
        if (sub.isEmpty()) {
            return false;
        } else {
            return (Boolean) node.getAttribute();
        }
    } else {
        final Hyperplane<Sphere2D> hyperplane = node.getCut().getHyperplane();
        final SubHyperplane.SplitSubHyperplane<Sphere2D> split = sub.split(hyperplane);
        switch (split.getSide()) {
        case PLUS:
            return recurseMeetInside(node.getPlus(), sub);
        case MINUS:
            return recurseMeetInside(node.getMinus(), sub);
        case BOTH:
            if (recurseMeetInside(node.getPlus(), split.getPlus())) {
                return true;
            } else {
                return recurseMeetInside(node.getMinus(), split.getMinus());
            }
        default:
            // this should not happen
            throw new OrekitInternalError(null);
        }
    }
}