Example usage for org.apache.commons.math3.geometry.spherical.twod Vertex getOutgoing

List of usage examples for org.apache.commons.math3.geometry.spherical.twod Vertex getOutgoing

Introduction

In this page you can find the example usage for org.apache.commons.math3.geometry.spherical.twod Vertex getOutgoing.

Prototype

public Edge getOutgoing() 

Source Link

Document

Get outgoing edge.

Usage

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

/** {@inheritDoc} */
@Override/*from   w w  w  .j  a  v  a2s.  c  om*/
public void visitLeafNode(final BSPTree<Sphere2D> node) {

    // we have already found a good point
    if (insidePointFirstChoice != null) {
        return;
    }

    if ((Boolean) node.getAttribute()) {

        // transform this inside leaf cell into a simple convex polygon
        final SphericalPolygonsSet convex = new SphericalPolygonsSet(
                node.pruneAroundConvexCell(Boolean.TRUE, Boolean.FALSE, null), zone.getTolerance());

        // extract the start of the single loop boundary of the convex cell
        final List<Vertex> boundary = convex.getBoundaryLoops();
        final Vertex start = boundary.get(0);
        int n = 0;
        Vector3D sumB = Vector3D.ZERO;
        for (Edge e = start.getOutgoing(); n == 0 || e.getStart() != start; e = e.getEnd().getOutgoing()) {
            sumB = new Vector3D(1, sumB, e.getLength(), e.getCircle().getPole());
            n++;
        }

        final S2Point candidate = new S2Point(sumB);

        // check the candidate point is really considered inside
        // it may appear outside if the current leaf cell is very thin
        // and checkPoint selects another (very close) tree leaf node
        if (zone.checkPoint(candidate) == Location.INSIDE) {
            insidePointFirstChoice = candidate;
        } else {
            insidePointSecondChoice = candidate;
        }

    }

}