/** * Returns a new volume that is translated so that * {@link BlockVolume#getBlockMin()} returns {@link Vector3i#ZERO}. This * does not copy the blocks, it only provides a new view of the storage. * * @return The new volume with its minimum at zero */ default BlockVolume getRelativeBlockView() { return getBlockView(DiscreteTransform3.fromTranslation(getBlockMin().negate())); }
/** * Returns a new transform representing a translation. * * @param x The x coordinate of the translation * @param y The y coordinate of the translation * @param z The z coordinate of the translation * @return The new translation transform */ public static DiscreteTransform3 fromTranslation(int x, int y, int z) { return new DiscreteTransform3(Matrix4d.createTranslation(x, y, z)); }
/** * Returns a transform that is the composition of the given transform with * this transform. The result will apply the given transformation after this * one. * * @param that The transform to compose with * @return The new composed transform */ public DiscreteTransform3 andThen(DiscreteTransform3 that) { return that.compose(this); }
/** * Transform a vector represented as a pair of * coordinates using this transform. * * @param x The x coordinate of the original vector * @param y The y coordinate of the original vector * @param z The z coordinate of the original vector * @return The transformed vector */ public Vector3i transform(int x, int y, int z) { return new Vector3i(transformX(x, y, z), transformY(x, y, z), transformZ(x, y, z)); }
/** * Adds another transformation to this transformation and * returns int as a new transform. * * @param transform The transformation to add * @return The added transforms as a copy */ public DiscreteTransform3 withTransformation(DiscreteTransform3 transform) { return new DiscreteTransform3(transform.getMatrix().mul(getMatrix())); }
/** * Returns a new transform representing a scaling. * The scale factor must be non-zero. * * @param a The scale factor * @return The new scale transform */ public static DiscreteTransform3 fromScale(int a) { return fromScale(a, a, a); }
/** * Adds a scale factor to this transform and returns * it as a new transform. This factor must be non-zero. * * @param a The scale factor * @return The scaled transform as a copy */ public DiscreteTransform3 withScale(int a) { return withScale(a, a, a); }
/** * Transforms the x coordinate of a vector * using this transform. Only creates a new * object on the first call. * * @param vector The original vector * @return The transformed x coordinate */ public int transformX(Vector3i vector) { return transformX(vector.getX(), vector.getY(), vector.getZ()); }
/** * Transforms the z coordinate of a vector * using this transform. Only creates a new * object on the first call. * * @param vector The original vector * @return The transformed z coordinate */ public int transformZ(Vector3i vector) { return transformZ(vector.getX(), vector.getY(), vector.getZ()); }
/** * Transforms the y coordinate of a vector * using this transform. Only creates a new * object on the first call. * * @param vector The original vector * @return The transformed y coordinate */ public int transformY(Vector3i vector) { return transformY(vector.getX(), vector.getY(), vector.getZ()); }
/** * Transforms a vector using this transforms. * * @param vector The original vector * @return The transformed vector */ public Vector3i transform(Vector3i vector) { return transform(vector.getX(), vector.getY(), vector.getZ()); }
/** * Transform a vector represented as a pair of * coordinates using this transform. * * @param x The x coordinate of the original vector * @param y The y coordinate of the original vector * @param z The z coordinate of the original vector * @return The transformed vector */ public Vector3i transform(int x, int y, int z) { return new Vector3i(transformX(x, y, z), transformY(x, y, z), transformZ(x, y, z)); }
/** * Adds another transformation to this transformation and * returns int as a new transform. * * @param transform The transformation to add * @return The added transforms as a copy */ public DiscreteTransform3 withTransformation(DiscreteTransform3 transform) { return new DiscreteTransform3(transform.getMatrix().mul(getMatrix())); }
/** * Returns a new transform representing a scaling on each axis. * The scale factors must be non-zero. * * @param vector The scale vector * @return The new scale transform */ public static DiscreteTransform3 fromScale(Vector3i vector) { return fromScale(vector.getX(), vector.getY(), vector.getZ()); }
/** * Adds a scale factor for each axis to this transform * and returns it as a new transform. The factors must * be non-zero. * * @param vector The scale vector * @return The scaled transform as a copy */ public DiscreteTransform3 withScale(Vector3i vector) { return withScale(vector.getX(), vector.getY(), vector.getZ()); }
/** * Transforms the x coordinate of a vector * using this transform. Only creates a new * object on the first call. * * @param vector The original vector * @return The transformed x coordinate */ public int transformX(Vector3i vector) { return transformX(vector.getX(), vector.getY(), vector.getZ()); }
/** * Transforms the z coordinate of a vector * using this transform. Only creates a new * object on the first call. * * @param vector The original vector * @return The transformed z coordinate */ public int transformZ(Vector3i vector) { return transformZ(vector.getX(), vector.getY(), vector.getZ()); }
/** * Transforms the y coordinate of a vector * using this transform. Only creates a new * object on the first call. * * @param vector The original vector * @return The transformed y coordinate */ public int transformY(Vector3i vector) { return transformY(vector.getX(), vector.getY(), vector.getZ()); }
/** * Transforms a vector using this transforms. * * @param vector The original vector * @return The transformed vector */ public Vector3i transform(Vector3i vector) { return transform(vector.getX(), vector.getY(), vector.getZ()); }
/** * Returns a new volume that is translated so that * {@link BiomeVolume#getBiomeMin()} returns {@link Vector2i#ZERO}. This * does not copy the biomes, it only provides a new view of the storage. * * @return The new volume with its minimum at zero */ default BiomeVolume getRelativeBiomeView() { return getBiomeView(DiscreteTransform3.fromTranslation(getBiomeMin().negate())); }