コード例 #1
0
ファイル: XdYZSolid.java プロジェクト: PATRIC3/p3_solr
 @Override
 public boolean isWithin(final double x, final double y, final double z) {
   return minXPlane.isWithin(x, y, z)
       && maxXPlane.isWithin(x, y, z)
       && yPlane.evaluateIsZero(x, y, z)
       && minZPlane.isWithin(x, y, z)
       && maxZPlane.isWithin(x, y, z);
 }
コード例 #2
0
ファイル: XdYZSolid.java プロジェクト: PATRIC3/p3_solr
 @Override
 public int hashCode() {
   int result = super.hashCode();
   result = 31 * result + minXPlane.hashCode();
   result = 31 * result + maxXPlane.hashCode();
   result = 31 * result + yPlane.hashCode();
   result = 31 * result + minZPlane.hashCode();
   result = 31 * result + maxZPlane.hashCode();
   return result;
 }
コード例 #3
0
ファイル: XdYZSolid.java プロジェクト: PATRIC3/p3_solr
  /**
   * 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 minZ is the minimum Z value.
   * @param maxZ is the maximum Z value.
   */
  public XdYZSolid(
      final PlanetModel planetModel,
      final double minX,
      final double maxX,
      final double Y,
      final double minZ,
      final double maxZ) {
    super(planetModel);
    // Argument checking
    if (maxX - minX < Vector.MINIMUM_RESOLUTION)
      throw new IllegalArgumentException("X values in wrong order or identical");
    if (maxZ - minZ < Vector.MINIMUM_RESOLUTION)
      throw new IllegalArgumentException("Z values in wrong order or identical");

    final double worldMinY = planetModel.getMinimumYValue();
    final double worldMaxY = planetModel.getMaximumYValue();

    // Construct the planes
    minXPlane = new SidedPlane(maxX, 0.0, 0.0, xUnitVector, -minX);
    maxXPlane = new SidedPlane(minX, 0.0, 0.0, xUnitVector, -maxX);
    yPlane = new Plane(yUnitVector, -Y);
    minZPlane = new SidedPlane(0.0, 0.0, maxZ, zUnitVector, -minZ);
    maxZPlane = new SidedPlane(0.0, 0.0, minZ, zUnitVector, -maxZ);

    // We need at least one point on the planet surface for each manifestation of the shape.
    // There can be up to 2 (on opposite sides of the world).  But we have to go through
    // 4 combinations of adjacent planes in order to find out if any have 2 intersection solution.
    // Typically, this requires 4 square root operations.
    final GeoPoint[] minXY =
        minXPlane.findIntersections(planetModel, yPlane, maxXPlane, minZPlane, maxZPlane);
    final GeoPoint[] maxXY =
        maxXPlane.findIntersections(planetModel, yPlane, minXPlane, minZPlane, maxZPlane);
    final GeoPoint[] YminZ =
        yPlane.findIntersections(planetModel, minZPlane, maxZPlane, minXPlane, maxXPlane);
    final GeoPoint[] YmaxZ =
        yPlane.findIntersections(planetModel, maxZPlane, minZPlane, minXPlane, maxXPlane);

    notableYPoints = glueTogether(minXY, maxXY, YminZ, YmaxZ);

    // Now, compute the edge points.
    // This is the trickiest part of setting up an XYZSolid.  We've computed intersections already,
    // so
    // we'll start there.  We know that at most there will be two disconnected shapes on the planet
    // surface.
    // But there's also a case where exactly one plane slices through the world, and none of the
    // bounding plane
    // intersections do.  Thus, if we don't find any of the edge intersection cases, we have to look
    // for that last case.

    // We need to look at single-plane/world intersections.
    // We detect these by looking at the world model and noting its x, y, and z bounds.
    // The cases we are looking for are when the four corner points for any given
    // plane are all outside of the world, AND that plane intersects the world.
    // There are four corner points all told; we must evaluate these WRT the planet surface.
    final boolean minXYminZ = planetModel.pointOutside(minX, Y, minZ);
    final boolean minXYmaxZ = planetModel.pointOutside(minX, Y, maxZ);
    final boolean maxXYminZ = planetModel.pointOutside(maxX, Y, minZ);
    final boolean maxXYmaxZ = planetModel.pointOutside(maxX, Y, maxZ);

    final GeoPoint[] yEdges;
    if (Y - worldMinY >= -Vector.MINIMUM_RESOLUTION
        && Y - worldMaxY <= Vector.MINIMUM_RESOLUTION
        && minX < 0.0
        && maxX > 0.0
        && minZ < 0.0
        && maxZ > 0.0
        && minXYminZ
        && minXYmaxZ
        && maxXYminZ
        && maxXYmaxZ) {
      // Find any point on the minY plane that intersects the world
      // First construct a perpendicular plane that will allow us to find a sample point.
      // This plane is vertical and goes through the points (0,0,0) and (0,1,0)
      // Then use it to compute a sample point.
      final GeoPoint intPoint = yPlane.getSampleIntersectionPoint(planetModel, yVerticalPlane);
      if (intPoint != null) {
        yEdges = new GeoPoint[] {intPoint};
      } else {
        yEdges = EMPTY_POINTS;
      }
    } else {
      yEdges = EMPTY_POINTS;
    }

    this.edgePoints = glueTogether(minXY, maxXY, YminZ, YmaxZ, yEdges);
  }