Beispiel #1
0
  public boolean isEqual(Point3D other) {
    if ((Math.abs(Double.parseDouble(x) - Double.parseDouble(other.getX())) <= Epsilon)
        && (Math.abs(Double.parseDouble(y) - Double.parseDouble(other.getY())) <= Epsilon)
        && (Math.abs(Double.parseDouble(z) - Double.parseDouble(other.getZ())) <= Epsilon))
      return true;

    return false;
  }
Beispiel #2
0
 public void setVertexAt(int index, Point3D v) {
   Point3D vertex = vertices.get(index);
   // System.out.println("original: " + vertex);
   // System.out.println("new: " + v);
   vertex.setX(v.getX());
   vertex.setY(v.getY());
   vertex.setZ(v.getZ());
 }
Beispiel #3
0
 public void addVertex(Point3D p) {
   vertices.add(new Point3D(p.getX(), p.getY(), p.getZ()));
   N++;
 }
Beispiel #4
0
  // Line 1: p0, p1
  // Line 2: p2, p3
  public Point3D getInteraction(Point3D p0, Point3D p1, Point3D p2, Point3D p3) {
    // x = x1 + a*t, y = y1 + b*t, and z = z1 + c*t;
    // x = x2 + d*s, y = y2 + e*s, and z = z2 + f*s
    double s = 0, t = 0;
    // Point3D AB = VO3D.diff_vector(p1, p0);
    // Point3D CD = VO3D.diff_vector(p3, p2);
    // System.out.println("p0 " + p0);
    // System.out.println("p1 " + p1);
    // System.out.println("p2 " + p2);
    // System.out.println("p3 " + p3);
    // System.out.println("AB " + AB);
    // System.out.println("CD " + CD);

    /*
     * if(AB.getX()==0){ System.out.println("here!"); return null; }
     *
     * if(AB.getX()*CD.getY()-AB.getY()*CD.getX() == 0){ return null; }
     */
    // if((p0.getX()-p1.getX())*(p3.getY()-p2.getY()) -
    // (p3.getX()-p2.getX())*(p0.getY()-p1.getY()) == 0)
    // return null;

    // System.out.println("upper: " +
    // ((p0.getY()-p2.getY())*AB.getX()+(p2.getX()-p0.getX())*AB.getY()));
    // System.out.println("lower: " +
    // (AB.getX()*CD.getY()-AB.getY()*CD.getX()));
    // double s =
    // ((p0.getY()-p2.getY())*AB.getX()+(p2.getX()-p0.getX())*AB.getY())/(AB.getX()*CD.getY()-AB.getY()*CD.getX());
    // double t = (p2.getX()-p0.getX()+CD.getX()*s)/AB.getX();
    if (ptype.equals(AddressBook.Triangle_Equ_Str)) {
      s = 0.3333333333333333;
      t = 0.3333333333333333;
    } else {
      s =
          ((p3.getY() - p1.getY()) * (p0.getX() - p1.getX())
                  - (p3.getX() - p1.getX()) * (p0.getY() - p1.getY()))
              / ((p0.getX() - p1.getX()) * (p3.getY() - p2.getY())
                  - (p3.getX() - p2.getX()) * (p0.getY() - p1.getY()));
      t = ((p3.getX() - p1.getX()) - (p3.getX() - p2.getX()) * s) / (p0.getX() - p1.getX());
    }
    // System.out.println("s = " + s);
    // System.out.println("t = " + t);
    double x = (p0.getX() - p1.getX()) * t + p1.getX();
    double y = (p0.getY() - p1.getY()) * t + p1.getY();
    double z = (p0.getZ() - p1.getZ()) * t + p1.getZ();

    return new Point3D(x, y, z);
  }
  // replaces rifts in game that have been destroyed/have blocks placed over them.
  private void onTickInGame() {

    try {

      if (tickCount > 100) {
        tickCount = 0;
        int i = 0;

        while (i < 15 && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
          i++;
          LinkData link;

          // actually gets the random rift based on the size of the list
          link = (LinkData) dimHelper.instance.getRandomLinkData(true);

          if (link != null) {

            if (dimHelper.getWorld(link.locDimID) != null) {
              World world = dimHelper.getWorld(link.locDimID);

              int blocktoReplace = world.getBlockId(link.locXCoord, link.locYCoord, link.locZCoord);

              if (!mod_pocketDim.blocksImmuneToRift.contains(
                  blocktoReplace)) // makes sure the rift doesnt replace a door or something
              {
                if (dimHelper.instance.getLinkDataFromCoords(
                        link.locXCoord, link.locYCoord, link.locZCoord, link.locDimID)
                    == null) {
                } else {
                  dimHelper
                      .getWorld(link.locDimID)
                      .setBlock(
                          link.locXCoord,
                          link.locYCoord,
                          link.locZCoord,
                          mod_pocketDim.blockRiftID);
                  TileEntityRift.class.cast(
                              dimHelper
                                  .getWorld(link.locDimID)
                                  .getBlockTileEntity(
                                      link.locXCoord, link.locYCoord, link.locZCoord))
                          .hasGrownRifts =
                      true;
                }
              }
            }
          }
        }
      }

    } catch (Exception e) {
      tickCount++;
      System.out.println("something on tick went wrong");
    }
    tickCount++;

    // this section regulates decay in Limbo- it records any blocks placed by the player and later
    // progresss them through the decay cycle
    if (tickCount2 > 10 && dimHelper.blocksToDecay != null) {
      tickCount2 = 0;
      if (!dimHelper.blocksToDecay.isEmpty()
          && dimHelper.getWorld(mod_pocketDim.limboDimID) != null) {

        if (dimHelper.blocksToDecay.size() > rand.nextInt(400)) {
          int index = rand.nextInt(dimHelper.blocksToDecay.size());
          Point3D point = (Point3D) dimHelper.blocksToDecay.get(index);

          int blockID =
              dimHelper
                  .getWorld(mod_pocketDim.limboDimID)
                  .getBlockId(point.getX(), point.getY(), point.getZ());
          int idToSet = Block.stone.blockID;

          if (blockID == 0 || blockID == mod_pocketDim.blockLimboID) {
            dimHelper.blocksToDecay.remove(index);
          } else {
            if (Block.blocksList[idToSet] instanceof BlockContainer) {
              idToSet = -1;
              dimHelper.blocksToDecay.remove(index);
            }

            if (blockID == Block.cobblestone.blockID) {
              idToSet = Block.gravel.blockID;
            }
            if (blockID == Block.stone.blockID) {
              idToSet = Block.cobblestone.blockID;
            }
            if (blockID == Block.gravel.blockID
                && !dimHelper
                    .getWorld(mod_pocketDim.limboDimID)
                    .isAirBlock(point.getX(), point.getY() - 1, point.getZ())) {
              idToSet = mod_pocketDim.blockLimboID;
              dimHelper
                  .getWorld(mod_pocketDim.limboDimID)
                  .scheduleBlockUpdate(point.getX(), point.getY(), point.getZ(), 10, idToSet);

            } else if (blockID == Block.gravel.blockID) {
              dimHelper.blocksToDecay.remove(index);
              idToSet = -1;
            }

            if (idToSet != -1) {

              dimHelper
                  .getWorld(mod_pocketDim.limboDimID)
                  .setBlock(point.getX(), point.getY(), point.getZ(), idToSet);
            }
          }
        }
      }
    }

    tickCount2++;

    if (mod_pocketDim.teleTimer > 0) {
      mod_pocketDim.teleTimer--;
    }
  }
Beispiel #6
0
 public void vectorMultiply(Point3D point) {
   p[0] = p[0] * point.getX();
   p[1] = p[1] * point.getY();
   p[2] = p[2] * point.getZ();
 }
Beispiel #7
0
 public void set(Point3D p) {
   this.p[0] = p.getX();
   this.p[1] = p.getY();
   this.p[2] = p.getZ();
 }
Beispiel #8
0
 public Point3D(Point3D p) {
   this.p[0] = p.getX();
   this.p[1] = p.getY();
   this.p[2] = p.getZ();
 }
 /** * METHODS ** */
 public double distance(Point3D p1) {
   float dx = x - p1.getX();
   float dy = y - p1.getY();
   float dz = z - p1.getZ();
   return Math.sqrt((dx * dx) + (dy * dy) + (dz * dz));
 }