List of usage examples for org.apache.commons.math3.geometry.spherical.twod S2Point S2Point
public S2Point(final double theta, final double phi) throws OutOfRangeException
From source file:org.orekit.models.earth.tessellation.EllipsoidTessellator.java
/** Build a simple zone (connected zone without holes). * <p>/*from w w w . j a v a 2s . c o m*/ * In order to build more complex zones (not connected or with * holes), the user should directly call Apache Commons * Math {@link SphericalPolygonsSet} constructors and * {@link RegionFactory region factory} if set operations * are needed (union, intersection, difference ...). * </p> * <p> * Take care that the vertices boundary points must be given <em>counterclockwise</em>. * Using the wrong order defines the complementary of the real zone, * and will often result in tessellation failure as the zone is too * wide. * </p> * @param tolerance angular separation below which points are considered * equal (typically 1.0e-10) * @param points vertices of the boundary, in <em>counterclockwise</em> * order, each point being a two-elements arrays with latitude at index 0 * and longitude at index 1 * @return a zone defined on the unit 2-sphere */ public static SphericalPolygonsSet buildSimpleZone(final double tolerance, final double[]... points) { final S2Point[] vertices = new S2Point[points.length]; for (int i = 0; i < points.length; ++i) { vertices[i] = new S2Point(points[i][1], 0.5 * FastMath.PI - points[i][0]); } return new SphericalPolygonsSet(tolerance, vertices); }
From source file:org.orekit.models.earth.tessellation.EllipsoidTessellator.java
/** Build a simple zone (connected zone without holes). * <p>// www.ja v a 2 s . c o m * In order to build more complex zones (not connected or with * holes), the user should directly call Apache Commons * Math {@link SphericalPolygonsSet} constructors and * {@link RegionFactory region factory} if set operations * are needed (union, intersection, difference ...). * </p> * <p> * Take care that the vertices boundary points must be given <em>counterclockwise</em>. * Using the wrong order defines the complementary of the real zone, * and will often result in tessellation failure as the zone is too * wide. * </p> * @param tolerance angular separation below which points are considered * equal (typically 1.0e-10) * @param points vertices of the boundary, in <em>counterclockwise</em> * order * @return a zone defined on the unit 2-sphere */ public static SphericalPolygonsSet buildSimpleZone(final double tolerance, final GeodeticPoint... points) { final S2Point[] vertices = new S2Point[points.length]; for (int i = 0; i < points.length; ++i) { vertices[i] = new S2Point(points[i].getLongitude(), 0.5 * FastMath.PI - points[i].getLatitude()); } return new SphericalPolygonsSet(tolerance, vertices); }
From source file:org.orekit.models.earth.tessellation.EllipsoidTessellatorTest.java
private S2Point toS2Point(final GeodeticPoint point) { return new S2Point(point.getLongitude(), 0.5 * FastMath.PI - point.getLatitude()); }
From source file:org.orekit.propagation.events.GeographicZoneDetector.java
/** Compute the value of the detection function. * <p>//w w w . j ava 2 s . c o m * 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)) { // we know we are strictly outside of the zone, // use the crude distance to compute the (positive) return value return crudeDistance - margin; } // we are close, we need to compute carefully the exact offset // project the point to the closest zone boundary return zone.projectToBoundary(s2p).getOffset() - margin; }
From source file:org.orekit.propagation.events.GeographicZoneDetectorTest.java
private SphericalPolygonsSet buildSimpleZone(double[][] points) { final S2Point[] vertices = new S2Point[points.length]; for (int i = 0; i < points.length; ++i) { vertices[i] = new S2Point(FastMath.toRadians(points[i][1]), // points[i][1] is longitude FastMath.toRadians(90.0 - points[i][0])); // points[i][0] is latitude }/*from ww w . ja v a 2s . com*/ return new SphericalPolygonsSet(1.0e-10, vertices); }