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

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

Introduction

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

Prototype

public BSPTree<S> getMinus() 

Source Link

Document

Get the tree on the minus side of the cut hyperplane.

Usage

From source file:edu.stanford.cfuller.imageanalysistools.util.VoronoiDiagram.java

protected boolean isLeaf(BSPTree<Euclidean2D> node) {
    return node.getPlus() == null && node.getMinus() == null;
}

From source file:edu.stanford.cfuller.imageanalysistools.util.VoronoiDiagram.java

private void divideRecursive(BSPTree<Euclidean2D> leaf, List<PointPair> pairsToUse) {

    if (pairsToUse.isEmpty())
        return;/*from   w  w w.  j av  a 2  s.c  o m*/

    PointPair p = pairsToUse.remove(0);

    while (!leaf.insertCut(this.constructBisectingHyperplane(p.getFirst(), p.getSecond()))) {
        if (pairsToUse.isEmpty())
            return;
        p = pairsToUse.remove(0);
    }

    leaf.setAttribute(null);

    BSPTree<Euclidean2D> minus = leaf.getMinus();
    BSPTree<Euclidean2D> plus = leaf.getPlus();

    minus.setAttribute(null);
    plus.setAttribute(null);

    List<PointPair> secondPairs = new java.util.ArrayList<PointPair>();
    secondPairs.addAll(pairsToUse);

    divideRecursive(minus, pairsToUse);
    divideRecursive(plus, secondPairs);

}

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

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