/** * Get a region that contains the faces of this cuboid. * * @return a new complex region */ public Region getFaces() { Vector min = getMinimumPoint(); Vector max = getMaximumPoint(); return new RegionIntersection( // Project to Z-Y plane new CuboidRegion(pos1.setX(min.getX()), pos2.setX(min.getX())), new CuboidRegion(pos1.setX(max.getX()), pos2.setX(max.getX())), // Project to X-Y plane new CuboidRegion(pos1.setZ(min.getZ()), pos2.setZ(min.getZ())), new CuboidRegion(pos1.setZ(max.getZ()), pos2.setZ(max.getZ())), // Project to the X-Z plane new CuboidRegion(pos1.setY(min.getY()), pos2.setY(min.getY())), new CuboidRegion(pos1.setY(max.getY()), pos2.setY(max.getY()))); }
public Vector transform(final Vector vector) { final double[][] matrix = this.matrix.getMatrix(); final double x = vector.getX(); final double y = vector.getY(); final double z = vector.getZ(); vector.setX(matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z); vector.setY(matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z); vector.setZ(matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z); return vector; }
public Transform transform(final Vector vector0, final Vector vector1) { final double[][] matrix = this.matrix.getMatrix(); final double x = vector0.getX(); final double y = vector0.getY(); final double z = vector0.getZ(); vector1.setX(matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z); vector1.setY(matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z); vector1.setZ(matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z); return this; }
public void jump() { if (!jumped) { vel.setY(20); jumped = true; } }
@Test public void setYComponentTest_IllegalCase() { testVector1.setY(Double.NaN); assertFalse(Util.fuzzyEquals(testVector1._Y(), Double.NaN)); }
@Test public void setYComponentTest_LegalCase() { testVector1.setY(5); assertTrue(Util.fuzzyEquals(testVector1._Y(), 5)); }
/** * Flip the clipboard. * * @param dir direction to flip * @param aroundPlayer flip the offset around the player */ public void flip(FlipDirection dir, boolean aroundPlayer) { final int width = getWidth(); final int length = getLength(); final int height = getHeight(); switch (dir) { case WEST_EAST: final int wid = (int) Math.ceil(width / 2.0f); for (int xs = 0; xs < wid; ++xs) { for (int z = 0; z < length; ++z) { for (int y = 0; y < height; ++y) { BaseBlock old = data[xs][y][z].flip(dir); if (xs == width - xs - 1) continue; data[xs][y][z] = data[width - xs - 1][y][z].flip(dir); data[width - xs - 1][y][z] = old; } } } if (aroundPlayer) { offset = offset.setX(1 - offset.getX() - width); } break; case NORTH_SOUTH: final int len = (int) Math.ceil(length / 2.0f); for (int zs = 0; zs < len; ++zs) { for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { BaseBlock old = data[x][y][zs].flip(dir); if (zs == length - zs - 1) continue; data[x][y][zs] = data[x][y][length - zs - 1].flip(dir); data[x][y][length - zs - 1] = old; } } } if (aroundPlayer) { offset = offset.setZ(1 - offset.getZ() - length); } break; case UP_DOWN: final int hei = (int) Math.ceil(height / 2.0f); for (int ys = 0; ys < hei; ++ys) { for (int x = 0; x < width; ++x) { for (int z = 0; z < length; ++z) { BaseBlock old = data[x][ys][z].flip(dir); if (ys == height - ys - 1) continue; data[x][ys][z] = data[x][height - ys - 1][z].flip(dir); data[x][height - ys - 1][z] = old; } } } if (aroundPlayer) { offset = offset.setY(1 - offset.getY() - height); } break; } }