/** Constructor. * @param ab is the x/y scaling factor. * @param c is the z scaling factor. */ public PlanetModel(final double ab, final double c) { this.ab = ab; this.c = c; this.inverseAb = 1.0 / ab; this.inverseC = 1.0 / c; this.flattening = (ab - c) * inverseAb; this.squareRatio = (ab * ab - c * c) / (c * c); this.inverseAbSquared = inverseAb * inverseAb; this.inverseCSquared = inverseC * inverseC; this.NORTH_POLE = new GeoPoint(c, 0.0, 0.0, 1.0, Math.PI * 0.5, 0.0); this.SOUTH_POLE = new GeoPoint(c, 0.0, 0.0, -1.0, -Math.PI * 0.5, 0.0); this.MIN_X_POLE = new GeoPoint(ab, -1.0, 0.0, 0.0, 0.0, -Math.PI); this.MAX_X_POLE = new GeoPoint(ab, 1.0, 0.0, 0.0, 0.0, 0.0); this.MIN_Y_POLE = new GeoPoint(ab, 0.0, -1.0, 0.0, 0.0, -Math.PI * 0.5); this.MAX_Y_POLE = new GeoPoint(ab, 0.0, 1.0, 0.0, 0.0, Math.PI * 0.5); this.scale = (2.0 * ab + c)/3.0; this.inverseScale = 1.0 / scale; this.minimumPoleDistance = Math.min(surfaceDistance(NORTH_POLE, SOUTH_POLE), surfaceDistance(MIN_X_POLE, MAX_X_POLE)); }
@Override public double distance(Point from, Point to) { if (from instanceof Geo3dPointShape && to instanceof Geo3dPointShape) { GeoPointShape pointShape1 = ((Geo3dPointShape) from).shape; GeoPointShape pointShape2 = ((Geo3dPointShape) to).shape; return planetModel.surfaceDistance(pointShape1.getCenter(), pointShape2.getCenter()) * DistanceUtils.RADIANS_TO_DEGREES; } return distance(from, to.getX(), to.getY()); }
@Override public double distance(Point from, double toX, double toY) { GeoPoint fromGeoPoint; if (from instanceof Geo3dPointShape) { fromGeoPoint = (((Geo3dPointShape) from).shape).getCenter(); } else { fromGeoPoint = new GeoPoint(planetModel, from.getY() * DistanceUtils.DEGREES_TO_RADIANS, from.getX() * DistanceUtils.DEGREES_TO_RADIANS); } GeoPoint toGeoPoint = new GeoPoint(planetModel, toY * DistanceUtils.DEGREES_TO_RADIANS, toX * DistanceUtils.DEGREES_TO_RADIANS); return planetModel.surfaceDistance(fromGeoPoint, toGeoPoint) * DistanceUtils.RADIANS_TO_DEGREES; }