use of org.hipparchus.geometry.spherical.twod.S2Point in project Orekit by CS-SI.
the class InsideFinder method visitLeafNode.
/**
* {@inheritDoc}
*/
@Override
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);
// and checkPoint selects another (very close) tree leaf node
if (zone.checkPoint(candidate) == Location.INSIDE) {
insidePointFirstChoice = candidate;
} else {
insidePointSecondChoice = candidate;
}
}
}
use of org.hipparchus.geometry.spherical.twod.S2Point in project Orekit by CS-SI.
the class GeographicZoneDetector method g.
/**
* Compute the value of the detection function.
* <p>
* The value is the signed distance to boundary, minus the margin. It is
* positive if the spacecraft is outside of the zone and negative if it is inside.
* </p>
* @param s the current state information: date, kinematics, attitude
* @return signed distance to boundary minus the margin
* @exception OrekitException if some specific error occurs
*/
public double g(final SpacecraftState s) throws OrekitException {
// convert state to geodetic coordinates
final GeodeticPoint gp = body.transform(s.getPVCoordinates().getPosition(), s.getFrame(), s.getDate());
// map the point to a sphere (geodetic coordinates have already taken care of ellipsoid flatness)
final S2Point s2p = new S2Point(gp.getLongitude(), 0.5 * FastMath.PI - gp.getLatitude());
// for faster computation, we start using only the surrounding cap, to filter out
// far away points (which correspond to most of the points if the zone is small)
final double crudeDistance = cap.getCenter().distance(s2p) - cap.getRadius();
if (crudeDistance - margin > FastMath.max(FastMath.abs(margin), 0.01)) {
// use the crude distance to compute the (positive) return value
return crudeDistance - margin;
}
// project the point to the closest zone boundary
return zone.projectToBoundary(s2p).getOffset() - margin;
}
use of org.hipparchus.geometry.spherical.twod.S2Point in project Orekit by CS-SI.
the class DOPComputation method computeSPS.
/**
* Computes a spherical polygons set from a geographic zone.
*
* @param zone the geographic zone
* @return the spherical polygons set
*/
private static SphericalPolygonsSet computeSPS(final List<GeodeticPoint> zone) {
// Convert the area into a SphericalPolygonsSet
final S2Point[] vertices = new S2Point[zone.size()];
int i = 0;
for (GeodeticPoint point : zone) {
final double theta = point.getLongitude();
final double phi = 0.5 * FastMath.PI - point.getLatitude();
vertices[i++] = new S2Point(theta, phi);
}
return new SphericalPolygonsSet(1.0e-10, vertices);
}
Aggregations