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

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

Introduction

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

Prototype

boolean isEmpty();

Source Link

Document

Check if the instance is empty.

Usage

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

/** Check if an arc meets the inside of a zone.
 * <p>//from  ww  w  . j ava  2s . c om
 * 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);
        }
    }
}