Example usage for org.apache.commons.math3.geometry.spherical.twod S2Point S2Point

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

Introduction

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

Prototype

public S2Point(final Vector3D vector) throws MathArithmeticException 

Source Link

Document

Simple constructor.

Usage

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

/** {@inheritDoc} */
@Override//from ww  w .j  av a  2  s.com
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;
        }

    }

}