/** * Find a sample point on the intersection between two planes and the world. * @param planetModel is the planet model. * @param q is the second plane to consider. * @return a sample point that is on the intersection between the two planes and the world. */ public GeoPoint getSampleIntersectionPoint(final PlanetModel planetModel, final Plane q) { final GeoPoint[] intersections = findIntersections(planetModel, q, NO_BOUNDS, NO_BOUNDS); if (intersections.length == 0) return null; return intersections[0]; }
/** * Find the intersection points between two planes, given a set of bounds. * @param planetModel is the planet model. * @param q is the plane to intersect with. * @param bounds are the bounds to consider to determine legal intersection points. * @return the set of legal intersection points, or null if the planes are numerically identical. */ public GeoPoint[] findIntersections(final PlanetModel planetModel, final Plane q, final Membership... bounds) { if (isNumericallyIdentical(q)) { return null; } return findIntersections(planetModel, q, bounds, NO_BOUNDS); }
/** Find the intersections with an envelope plane, and assess those intersections for * whether they truly describe crossings. */ private int countCrossings(final Edge edge, final Plane envelopePlane, final Membership envelopeBound) { final GeoPoint[] intersections = edge.plane.findIntersections(planetModel, envelopePlane, envelopeBound); int crossings = 0; if (intersections != null) { for (final GeoPoint intersection : intersections) { if (edge.startPlane.strictlyWithin(intersection) && edge.endPlane.strictlyWithin(intersection)) { // It's unique, so assess it crossings += edgeCrossesEnvelope(edge.plane, intersection, envelopePlane)?1:0; } } } return crossings; }
/** Find the intersections with an envelope plane, and assess those intersections for * whether they truly describe crossings. */ private int countCrossings(final Edge edge, final Plane envelopePlane, final Membership envelopeBound1, final Membership envelopeBound2) { final GeoPoint[] intersections = edge.plane.findIntersections(planetModel, envelopePlane, envelopeBound1, envelopeBound2); int crossings = 0; if (intersections != null) { for (final GeoPoint intersection : intersections) { if (edge.startPlane.strictlyWithin(intersection) && edge.endPlane.strictlyWithin(intersection)) { //System.out.println(" Envelope intersection point = "+intersection); // It's unique, so assess it final int counter = edgeCrossesEnvelope(edge.plane, intersection, envelopePlane)?1:0; //System.out.println(" Edge crosses envelope "+counter+" times"); crossings += counter; } } } else { //System.out.println(" Intersections = null"); } return crossings; }
/** * 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); }
/** * Sole constructor * *@param planetModel is the planet model. *@param X is the X value. *@param Y is the Y value. *@param minZ is the minimum Z value. *@param maxZ is the maximum Z value. */ public dXdYZSolid(final PlanetModel planetModel, final double X, final double Y, final double minZ, final double maxZ) { super(planetModel); // Argument checking if (maxZ - minZ < Vector.MINIMUM_RESOLUTION) throw new IllegalArgumentException("Z values in wrong order or identical"); this.X = X; this.Y = Y; this.minZ = minZ; this.maxZ = maxZ; // Build the planes and intersect them. final Plane xPlane = new Plane(xUnitVector,-X); final Plane yPlane = new Plane(yUnitVector,-Y); final SidedPlane minZPlane = new SidedPlane(0.0,0.0,maxZ,zUnitVector,-minZ); final SidedPlane maxZPlane = new SidedPlane(0.0,0.0,minZ,zUnitVector,-maxZ); surfacePoints = xPlane.findIntersections(planetModel,yPlane,minZPlane,maxZPlane); }
/** * Sole constructor * *@param planetModel is the planet model. *@param X is the X value. *@param minY is the minimum Y value. *@param maxY is the maximum Y value. *@param Z is the Z value. */ public dXYdZSolid(final PlanetModel planetModel, final double X, final double minY, final double maxY, final double Z) { super(planetModel); // Argument checking if (maxY - minY < Vector.MINIMUM_RESOLUTION) throw new IllegalArgumentException("Y values in wrong order or identical"); this.X = X; this.minY = minY; this.maxY = maxY; this.Z = Z; // Build the planes and intersect them. final Plane xPlane = new Plane(xUnitVector,-X); final Plane zPlane = new Plane(zUnitVector,-Z); final SidedPlane minYPlane = new SidedPlane(0.0,maxY,0.0,yUnitVector,-minY); final SidedPlane maxYPlane = new SidedPlane(0.0,minY,0.0,yUnitVector,-maxY); surfacePoints = xPlane.findIntersections(planetModel,zPlane,minYPlane,maxYPlane); }
final Plane normalizedPerpPlane = new Plane(perpX * normFactor, perpY * normFactor, perpZ * normFactor, 0.0); final GeoPoint[] intersectionPoints = normalizedConnectingPlane.findIntersections(planetModel, normalizedPerpPlane); GeoPoint thePoint; if (intersectionPoints.length == 0)
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 Plane normalizedPerpPlane = new Plane(perpX * normFactor, perpY * normFactor, perpZ * normFactor, 0.0); final GeoPoint[] intersectionPoints = normalizedConnectingPlane.findIntersections(planetModel, normalizedPerpPlane); GeoPoint thePoint; if (intersectionPoints.length == 0)
final Plane normalizedPerpPlane = new Plane(perpX * normFactor, perpY * normFactor, perpZ * normFactor, 0.0); final GeoPoint[] intersectionPoints = normalizedConnectingPlane.findIntersections(planetModel, normalizedPerpPlane); GeoPoint thePoint; if (intersectionPoints.length == 0)
final Plane normalizedPerpPlane = new Plane(perpX * normFactor, perpY * normFactor, perpZ * normFactor, 0.0); final GeoPoint[] intersectionPoints = normalizedConnectingPlane.findIntersections(planetModel, normalizedPerpPlane); GeoPoint thePoint; if (intersectionPoints.length == 0)
final GeoPoint[] intersectionPoints = normalizedConnectingPlane.findIntersections(planetModel, normalizedPerpPlane); GeoPoint thePoint; if (intersectionPoints.length == 0)
@Override public boolean matches(final Edge edge) { //System.out.println(" Edge ["+edge.startPoint+" --> "+edge.endPoint+"] potentially crosses travel plane "+plane); // Early exit if the point is on the edge. if (edge.isWithin(thePointX, thePointY, thePointZ)) { //System.out.println(" Point is on the edge; in-set"); onEdge = true; return false; } // This should precisely mirror what is in DualCrossingIterator, but without the dual crossings. // Some edges are going to be given to us even when there's no real intersection, so do that as a sanity check, first. final GeoPoint[] planeCrossings = plane.findIntersections(planetModel, edge.plane, bound, edge.startPlane, edge.endPlane); if (planeCrossings != null && planeCrossings.length == 0) { // Sometimes on the hairy edge an intersection will be missed. This check finds those. if (!plane.evaluateIsZero(edge.startPoint) && !plane.evaluateIsZero(edge.endPoint)) { return true; } } //System.out.println(" Edge intersects travel plane "+plane); // Determine crossings of this edge against all inside/outside planes. There's no further need to look at the actual travel plane itself. final int aboveCrossings = countCrossings(edge, abovePlane, bound); aboveCrossingCount += aboveCrossings; final int belowCrossings = countCrossings(edge, belowPlane, bound); belowCrossingCount += belowCrossings; //System.out.println(" Above crossings = "+aboveCrossings+"; below crossings = "+belowCrossings); return true; }
final GeoPoint[] intersectionPoints = findIntersections(planetModel, perpPlane);
final Plane travelEnvelopePlane, final Membership travelEnvelopeBound1, final Membership travelEnvelopeBound2, final Plane testPointEnvelopePlane, final Membership testPointEnvelopeBound1, final Membership testPointEnvelopeBound2) { final GeoPoint[] travelIntersections = edge.plane.findIntersections(planetModel, travelEnvelopePlane, travelEnvelopeBound1, travelEnvelopeBound2); final GeoPoint[] testPointIntersections = edge.plane.findIntersections(planetModel, testPointEnvelopePlane, testPointEnvelopeBound1, testPointEnvelopeBound2); int crossings = 0; if (travelIntersections != null) {
final GeoPoint[] intersectionPoints = findIntersections(planetModel, perpPlane);
final GeoPoint[] intersectionPoints = normalizedConnectingPlane.findIntersections(planetModel, normalizedPerpPlane); GeoPoint thePoint; if (intersectionPoints.length == 0)
final GeoPoint[] intersectionPoints = normalizedConnectingPlane.findIntersections(planetModel, normalizedPerpPlane); GeoPoint thePoint; if (intersectionPoints.length == 0)
final GeoPoint[] planeCrossings = plane.findIntersections(planetModel, edge.plane, bound1, bound2, edge.startPlane, edge.endPlane); if (planeCrossings == null) {