Example usage for org.apache.commons.math3.geometry.partitioning BSPTree getCut

List of usage examples for org.apache.commons.math3.geometry.partitioning BSPTree getCut

Introduction

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

Prototype

public SubHyperplane<S> getCut() 

Source Link

Document

Get the cut sub-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 .j a v a  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);
        }
    }
}