/** * Sole constructor * *@param planetModel is the planet model. *@param minX is the minimum X value. *@param maxX is the maximum X value. *@param Y is the Y value. *@param Z is the Z value. */ public XdYdZSolid(final PlanetModel planetModel, final double minX, final double maxX, final double Y, final double Z) { super(planetModel); // Argument checking if (maxX - minX < Vector.MINIMUM_RESOLUTION) throw new IllegalArgumentException("X values in wrong order or identical"); this.minX = minX; this.maxX = maxX; this.Y = Y; this.Z = Z; // Build the planes and intersect them. final Plane yPlane = new Plane(yUnitVector,-Y); final Plane zPlane = new Plane(zUnitVector,-Z); final SidedPlane minXPlane = new SidedPlane(maxX,0.0,0.0,xUnitVector,-minX); final SidedPlane maxXPlane = new SidedPlane(minX,0.0,0.0,xUnitVector,-maxX); surfacePoints = yPlane.findIntersections(planetModel,zPlane,minXPlane,maxXPlane); }
/** Compute arc distance from plane to a vector expressed with a {@link GeoPoint}. * @see #arcDistance(PlanetModel, double, double, double, Membership...) */ public double arcDistance(final PlanetModel planetModel, final GeoPoint v, final Membership... bounds) { return arcDistance(planetModel, v.x, v.y, v.z, bounds); }
/** * Construct a horizontal plane at a specified Z. * * @param planetModel is the planet model. * @param sinLat is the sin(latitude). */ public Plane(final PlanetModel planetModel, final double sinLat) { super(0.0, 0.0, 1.0); D = -sinLat * computeDesiredEllipsoidMagnitude(planetModel, sinLat); }
if (evaluateIsZero(x,y,z)) { if (meetsAllBounds(x,y,z, bounds)) return 0.0; return Double.POSITIVE_INFINITY; final Plane perpPlane = new Plane(this.y * z - this.z * y, this.z * x - this.x * z, this.x * y - this.y * x, 0.0); final GeoPoint[] intersectionPoints = findIntersections(planetModel, perpPlane); if (meetsAllBounds(intersectionPoint, bounds)) { final double theDistance = intersectionPoint.arcDistance(x,y,z); if (theDistance < minDistance) {
xPlane = new Plane(xUnitVector,-X); minYPlane = new SidedPlane(0.0,maxY,0.0,yUnitVector,-minY); maxYPlane = new SidedPlane(0.0,minY,0.0,yUnitVector,-maxY); final GeoPoint[] XminY = xPlane.findIntersections(planetModel,minYPlane,maxYPlane,minZPlane,maxZPlane); final GeoPoint[] XmaxY = xPlane.findIntersections(planetModel,maxYPlane,minYPlane,minZPlane,maxZPlane); final GeoPoint[] XminZ = xPlane.findIntersections(planetModel,minZPlane,maxZPlane,minYPlane,maxYPlane); final GeoPoint[] XmaxZ = xPlane.findIntersections(planetModel,maxZPlane,minZPlane,minYPlane,maxYPlane); final GeoPoint intPoint = xPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane); if (intPoint != null) { xEdges = new GeoPoint[]{intPoint};
final Plane verticalPlane = constructNormalizedZPlane(A,B); final GeoPoint[] points = findIntersections(planetModel, verticalPlane, bounds, NO_BOUNDS); for (final GeoPoint point : points) { addPoint(boundsInfo, bounds, point); final GeoPoint[] points = findIntersections(planetModel, normalXPlane, NO_BOUNDS, NO_BOUNDS); boundsInfo.addZValue(points[0]); double x0 = (-D - B * y0) / A; double z0 = 0.0; addPoint(boundsInfo, bounds, new GeoPoint(x0, y0, z0)); } else if (sqrtClause > 0.0) { double sqrtResult = Math.sqrt(sqrtClause); addPoint(boundsInfo, bounds, new GeoPoint(x0a, y0a, z0a)); addPoint(boundsInfo, bounds, new GeoPoint(x0b, y0b, z0b)); double y0 = (-D - A * x0) / B; double z0 = 0.0; addPoint(boundsInfo, bounds, new GeoPoint(x0, y0, z0)); } else if (sqrtClause > 0.0) { double sqrtResult = Math.sqrt(sqrtClause); addPoint(boundsInfo, bounds, new GeoPoint(x0a, y0a, z0a)); addPoint(boundsInfo, bounds, new GeoPoint(x0b, y0b, z0b)); addPoint(boundsInfo, bounds, new GeoPoint(x0, y0, z0)); } else if (sqrtClause > 0.0) {
/** Construct a normalized plane through a y-z point and parallel to the X axis. * If the y-z point is at (0,0), return null. * @param y is the y value. * @param z is the z value. * @param DValue is the offset from the origin for the plane. * @return a plane parallel to the X axis and perpendicular to the y and z values given. */ public static Plane constructNormalizedXPlane(final double y, final double z, final double DValue) { if (Math.abs(y) < MINIMUM_RESOLUTION && Math.abs(z) < MINIMUM_RESOLUTION) return null; final double denom = 1.0 / Math.sqrt(y*y + z*z); return new Plane(0.0, z * denom, -y * denom, DValue); }
if (testPointFixedYAbovePlane != null && testPointFixedYBelowPlane != null && testPointFixedYPlane.evaluateIsZero(x, y, z)) { } else if (testPointFixedXAbovePlane != null && testPointFixedXBelowPlane != null && testPointFixedXPlane.evaluateIsZero(x, y, z)) { } else if (testPointFixedZAbovePlane != null && testPointFixedZBelowPlane != null && testPointFixedZPlane.evaluateIsZero(x, y, z)) { final Plane travelPlaneFixedX = new Plane(1.0, 0.0, 0.0, -x); final Plane travelPlaneFixedY = new Plane(0.0, 1.0, 0.0, -y); final Plane travelPlaneFixedZ = new Plane(0.0, 0.0, 1.0, -z); Plane fixedYAbovePlane = new Plane(travelPlaneFixedY, true); if (-fixedYAbovePlane.D - planetModel.getMaximumYValue() > NEAR_EDGE_CUTOFF || planetModel.getMinimumYValue() + fixedYAbovePlane.D > NEAR_EDGE_CUTOFF) { fixedYAbovePlane = null; Plane fixedYBelowPlane = new Plane(travelPlaneFixedY, false); if (-fixedYBelowPlane.D - planetModel.getMaximumYValue() > NEAR_EDGE_CUTOFF || planetModel.getMinimumYValue() + fixedYBelowPlane.D > NEAR_EDGE_CUTOFF) { fixedYBelowPlane = null; Plane fixedXAbovePlane = new Plane(travelPlaneFixedX, true); if (-fixedXAbovePlane.D - planetModel.getMaximumXValue() > NEAR_EDGE_CUTOFF || planetModel.getMinimumXValue() + fixedXAbovePlane.D > NEAR_EDGE_CUTOFF) { fixedXAbovePlane = null; Plane fixedXBelowPlane = new Plane(travelPlaneFixedX, false); if (-fixedXBelowPlane.D - planetModel.getMaximumXValue() > NEAR_EDGE_CUTOFF || planetModel.getMinimumXValue() + fixedXBelowPlane.D > NEAR_EDGE_CUTOFF) { fixedXBelowPlane = null; Plane fixedZAbovePlane = new Plane(travelPlaneFixedZ, true); if (-fixedZAbovePlane.D - planetModel.getMaximumZValue() > NEAR_EDGE_CUTOFF || planetModel.getMinimumZValue() + fixedZAbovePlane.D > NEAR_EDGE_CUTOFF) { fixedZAbovePlane = null;
final Plane planeToFind = new Plane(start, end); int endPointIndex = -1; for (int j = 0; j < points.size(); j++) { final int index = legalIndex(j + i + 2); if (!planeToFind.evaluateIsZero(points.get(index))) { endPointIndex = index; break;
if (!Plane.arePointsCoplanar(startPoint, endPoint, nextPoint)) { Plane currentPlane = new Plane(startPoint, endPoint); safePath = new SafePath(safePath, endPoint, endPointIndex, currentPlane);
public Edge(final PlanetModel pm, final GeoPoint startPoint, final GeoPoint endPoint) { this.startPoint = startPoint; this.endPoint = endPoint; this.notablePoints = new GeoPoint[]{startPoint, endPoint}; this.plane = new Plane(startPoint, endPoint); this.startPlane = new SidedPlane(endPoint, plane, startPoint); this.endPlane = new SidedPlane(startPoint, plane, endPoint); final GeoPoint interpolationPoint = plane.interpolate(pm, startPoint, endPoint, halfProportions)[0]; this.backingPlane = new SidedPlane(interpolationPoint, interpolationPoint, 0.0); this.planeBounds = new XYZBounds(); this.planeBounds.addPoint(startPoint); this.planeBounds.addPoint(endPoint); this.planeBounds.addPlane(pm, this.plane, this.startPlane, this.endPlane, this.backingPlane); //System.out.println("Recording edge ["+startPoint+" --> "+endPoint+"]; bounds = "+planeBounds); }
for (final GeoPoint end : points) { if (lastPoint != null) { final Plane normalizedConnectingPlane = new Plane(lastPoint, end); if (normalizedConnectingPlane == null) { continue; final Plane normalPlane = Plane.constructNormalizedZPlane(upperPoint, lowerPoint, point);
minYPlane = new SidedPlane(0.0,maxY,0.0,yUnitVector,-minY); maxYPlane = new SidedPlane(0.0,minY,0.0,yUnitVector,-maxY); zPlane = new Plane(zUnitVector,-Z); final GeoPoint intPoint = zPlane.getSampleIntersectionPoint(planetModel, xVerticalPlane); if (intPoint != null) { zEdges = new GeoPoint[]{intPoint};
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof SidedPlane)) return false; if (!super.equals(o)) return false; SidedPlane that = (SidedPlane) o; return Double.compare(that.sigNum, sigNum) == 0; }
/** * Evaluate the plane equation for a given point, as represented * by a vector. * @param x is the x value. * @param y is the y value. * @param z is the z value. * @return the result of the evaluation. */ public double evaluate(final double x, final double y, final double z) { return dotProduct(x, y, z) + D; }
/** Construct the most accurate normalized plane through an x-y point and including the Z axis. * If none of the points can determine the plane, return null. * @param planePoints is a set of points to choose from. The best one for constructing the most precise plane is picked. * @return the plane */ public static Plane constructNormalizedZPlane(final Vector... planePoints) { // Pick the best one (with the greatest x-y distance) double bestDistance = 0.0; Vector bestPoint = null; for (final Vector point : planePoints) { final double pointDist = point.x * point.x + point.y * point.y; if (pointDist > bestDistance) { bestDistance = pointDist; bestPoint = point; } } return constructNormalizedZPlane(bestPoint.x, bestPoint.y); }
if (Plane.arePointsCoplanar(lastEdge.startPoint, lastEdge.endPoint, newLastEdge.endPoint)) { break; if (Plane.arePointsCoplanar(firstEdge.endPoint, firstEdge.startPoint, newLastEdge.endPoint) || Plane.arePointsCoplanar(firstEdge.startPoint, newLastEdge.endPoint, newLastEdge.startPoint)) { break; if (Plane.arePointsCoplanar(newFirstEdge.startPoint, newFirstEdge.endPoint, firstEdge.endPoint)) { break; if(Plane.arePointsCoplanar(lastEdge.startPoint, lastEdge.endPoint, newFirstEdge.startPoint) || Plane.arePointsCoplanar(lastEdge.endPoint, newFirstEdge.startPoint, newFirstEdge.endPoint)) { break;
/** Construct the most accurate normalized plane through an x-z point and including the Y axis. * If none of the points can determine the plane, return null. * @param planePoints is a set of points to choose from. The best one for constructing the most precise plane is picked. * @return the plane */ public static Plane constructNormalizedYPlane(final Vector... planePoints) { // Pick the best one (with the greatest x-z distance) double bestDistance = 0.0; Vector bestPoint = null; for (final Vector point : planePoints) { final double pointDist = point.x * point.x + point.z * point.z; if (pointDist > bestDistance) { bestDistance = pointDist; bestPoint = point; } } return constructNormalizedYPlane(bestPoint.x, bestPoint.z, 0.0); }
/** Construct the most accurate normalized plane through an y-z point and including the X axis. * If none of the points can determine the plane, return null. * @param planePoints is a set of points to choose from. The best one for constructing the most precise plane is picked. * @return the plane */ public static Plane constructNormalizedXPlane(final Vector... planePoints) { // Pick the best one (with the greatest y-z distance) double bestDistance = 0.0; Vector bestPoint = null; for (final Vector point : planePoints) { final double pointDist = point.y * point.y + point.z * point.z; if (pointDist > bestDistance) { bestDistance = pointDist; bestPoint = point; } } return constructNormalizedXPlane(bestPoint.y, bestPoint.z, 0.0); }
if (evaluateIsZero(x,y,z)) { if (meetsAllBounds(x,y,z, bounds)) return 0.0; return Double.POSITIVE_INFINITY; final Plane perpPlane = new Plane(this.y * z - this.z * y, this.z * x - this.x * z, this.x * y - this.y * x, 0.0); final GeoPoint[] intersectionPoints = findIntersections(planetModel, perpPlane); if (meetsAllBounds(intersectionPoint, bounds)) { final double theDistance = intersectionPoint.linearDistance(x,y,z); if (theDistance < minDistance) {