/** Compute a GeoPoint that's scaled to actually be on the planet surface. * @param vector is the vector. * @return the scaled point. */ public GeoPoint createSurfacePoint(final Vector vector) { return createSurfacePoint(vector.x, vector.y, vector.z); }
/** Generate a point at the center of mass of a list of points. */ private static GeoPoint getCenterOfMass(final PlanetModel planetModel, final List<GeoPoint> points) { double x = 0; double y = 0; double z = 0; //get center of mass for (final GeoPoint point : points) { x += point.x; y += point.y; z += point.z; } // Normalization is not needed because createSurfacePoint does the scaling anyway. return planetModel.createSurfacePoint(x, y, z); }
/** Given a point on the plane and the ellipsoid, this method looks for a pair of adjoining points on either side of the plane, which are * about MINIMUM_RESOLUTION away from the given point. This only works for planes which go through the center of the world. * Returns null if the planes are effectively parallel and reasonable adjoining points cannot be determined. */ private GeoPoint[] findAdjoiningPoints(final Plane plane, final GeoPoint pointOnPlane, final Plane envelopePlane) { // Compute a normalized perpendicular vector final Vector perpendicular = new Vector(plane, pointOnPlane); double distanceFactor = 0.0; for (int i = 0; i < MAX_ITERATIONS; i++) { distanceFactor += DELTA_DISTANCE; // Compute two new points along this vector from the original final GeoPoint pointA = planetModel.createSurfacePoint(pointOnPlane.x + perpendicular.x * distanceFactor, pointOnPlane.y + perpendicular.y * distanceFactor, pointOnPlane.z + perpendicular.z * distanceFactor); final GeoPoint pointB = planetModel.createSurfacePoint(pointOnPlane.x - perpendicular.x * distanceFactor, pointOnPlane.y - perpendicular.y * distanceFactor, pointOnPlane.z - perpendicular.z * distanceFactor); if (Math.abs(envelopePlane.evaluate(pointA)) > OFF_PLANE_AMOUNT && Math.abs(envelopePlane.evaluate(pointB)) > OFF_PLANE_AMOUNT) { //System.out.println("Distance: "+computeSquaredDistance(rval[0], pointOnPlane)+" and "+computeSquaredDistance(rval[1], pointOnPlane)); return new GeoPoint[]{pointA, pointB}; } // Loop back around and use a bigger delta } // Had to abort, so return null. //System.out.println(" Adjoining points not found. Are planes parallel? edge = "+plane+"; envelope = "+envelopePlane+"; perpendicular = "+perpendicular); return null; }
final double point2z0 = point2z1; final GeoPoint point1 = planetModel.createSurfacePoint(point1x0, point1y0, point1z0); final GeoPoint point2 = planetModel.createSurfacePoint(point2x0, point2y0, point2z0);
private GeoPoint getGeoPoint(S2Point point) { return planetModel.createSurfacePoint(point.get(0), point.get(1), point.get(2)); }
final double z2 = z1; return planetModel.createSurfacePoint(x2, y2, z2);
/** * Reverse modify a point to produce a GeoPoint in normal space. * @param planetModel is the planet model. * @param point is the translated point. * @param transX is the translation x value. * @param transY is the translation y value. * @param transZ is the translation z value. * @param sinRA is the sine of the ascension angle. * @param cosRA is the cosine of the ascension angle. * @param sinHA is the sine of the height angle. * @param cosHA is the cosine of the height angle. * @return the original point. */ protected static GeoPoint reverseModify(final PlanetModel planetModel, final Vector point, final double transX, final double transY, final double transZ, final double sinRA, final double cosRA, final double sinHA, final double cosHA) { final Vector result = point.rotateXZ(-sinHA, cosHA).rotateXY(-sinRA, cosRA).translate(-transX, -transY, -transZ); return planetModel.createSurfacePoint(result.x, result.y, result.z); }