public class DiscreteTransform3 extends Object
Rotations are performed around block centers unless the block corner flags are set to true. To prevent aliasing, quarter turn rotations are only legal on block centers or corners. Half turns can be performed additionally on edge and face centers.
Modifier and Type | Field and Description |
---|---|
static DiscreteTransform3 |
IDENTITY
Represents an identity transformation.
|
Modifier and Type | Method and Description |
---|---|
DiscreteTransform3 |
andThen(DiscreteTransform3 that)
Returns a transform that is the composition of the given transform with
this transform.
|
DiscreteTransform3 |
compose(DiscreteTransform3 that)
Returns a transform that is the composition of this transform and the
given transform.
|
static DiscreteTransform3 |
fromRotation(int quarterTurns,
Axis axis)
Returns a new transform representing a rotation around an
axis around the origin.
|
static DiscreteTransform3 |
fromRotation(int quarterTurns,
Axis axis,
com.flowpowered.math.vector.Vector3i point,
boolean blockCorner)
Returns a new transform representing a rotation around an axis,
around a given point.
|
static DiscreteTransform3 |
fromRotation(int halfTurns,
Axis axis,
com.flowpowered.math.vector.Vector3i point,
boolean blockCornerX,
boolean blockCornerY,
boolean blockCornerZ)
Returns a new transform representing a rotation around an axis,
around a given point.
|
static DiscreteTransform3 |
fromScale(int a)
Returns a new transform representing a scaling.
|
static DiscreteTransform3 |
fromScale(int x,
int y,
int z)
Returns a new transform representing a scaling on each axis.
|
static DiscreteTransform3 |
fromScale(com.flowpowered.math.vector.Vector3i vector)
Returns a new transform representing a scaling on each axis.
|
static DiscreteTransform3 |
fromTranslation(int x,
int y,
int z)
Returns a new transform representing a translation.
|
static DiscreteTransform3 |
fromTranslation(com.flowpowered.math.vector.Vector3i vector)
Returns a new transform representing a translation.
|
com.flowpowered.math.matrix.Matrix4d |
getMatrix()
Returns the matrix representation of the transform.
|
DiscreteTransform3 |
invert()
Inverts the transform and returns it as a new transform.
|
static Optional<DiscreteTransform3> |
of(com.flowpowered.math.matrix.Matrix4d matrix)
Returns a new transform from the given transformation matrix, if the
resulting transform would be discrete.
|
static DiscreteTransform3 |
rotationAroundCenter(int quarterTurns,
Axis axis,
com.flowpowered.math.vector.Vector3i size)
Returns a new transform representing a centered rotation of an volume
of blocks.
|
com.flowpowered.math.vector.Vector3i |
transform(int x,
int y,
int z)
Transform a vector represented as a pair of
coordinates using this transform.
|
com.flowpowered.math.vector.Vector3i |
transform(com.flowpowered.math.vector.Vector3i vector)
Transforms a vector using this transforms.
|
int |
transformX(int x,
int y,
int z)
Transforms the x coordinate of a vector
using this transform.
|
int |
transformX(com.flowpowered.math.vector.Vector3i vector)
Transforms the x coordinate of a vector
using this transform.
|
int |
transformY(int x,
int y,
int z)
Transforms the y coordinate of a vector
using this transform.
|
int |
transformY(com.flowpowered.math.vector.Vector3i vector)
Transforms the y coordinate of a vector
using this transform.
|
int |
transformZ(int x,
int y,
int z)
Transforms the z coordinate of a vector
using this transform.
|
int |
transformZ(com.flowpowered.math.vector.Vector3i vector)
Transforms the z coordinate of a vector
using this transform.
|
DiscreteTransform3 |
withRotation(int quarterTurns,
Axis axis)
Adds a rotation to this transform, around an axis,
around the origin and returns it as a new transform.
|
DiscreteTransform3 |
withRotation(int quarterTurns,
Axis axis,
com.flowpowered.math.vector.Vector3i point,
boolean blockCorner)
Adds a a rotation to this transform, around an axis,
around a given point, and returns it as a new transform.
|
DiscreteTransform3 |
withRotation(int halfTurns,
Axis axis,
com.flowpowered.math.vector.Vector3i point,
boolean blockCornerX,
boolean blockCornerY,
boolean blockCornerZ)
Adds a a rotation to this transform, around an axis,
around a given point.
|
DiscreteTransform3 |
withScale(int a)
Adds a scale factor to this transform and returns
it as a new transform.
|
DiscreteTransform3 |
withScale(int x,
int y,
int z)
Adds a scale factor for each axis to this transform
and returns it as a new transform.
|
DiscreteTransform3 |
withScale(com.flowpowered.math.vector.Vector3i vector)
Adds a scale factor for each axis to this transform
and returns it as a new transform.
|
DiscreteTransform3 |
withTransformation(DiscreteTransform3 transform)
Adds another transformation to this transformation and
returns int as a new transform.
|
DiscreteTransform3 |
withTranslation(int x,
int y,
int z)
Adds a translation to this transform and returns
it as a new transform.
|
DiscreteTransform3 |
withTranslation(com.flowpowered.math.vector.Vector3i vector)
Adds a translation to this transform and returns
it as a new transform.
|
public static final DiscreteTransform3 IDENTITY
public com.flowpowered.math.matrix.Matrix4d getMatrix()
public com.flowpowered.math.vector.Vector3i transform(com.flowpowered.math.vector.Vector3i vector)
vector
- The original vectorpublic com.flowpowered.math.vector.Vector3i transform(int x, int y, int z)
x
- The x coordinate of the original vectory
- The y coordinate of the original vectorz
- The z coordinate of the original vectorpublic int transformX(com.flowpowered.math.vector.Vector3i vector)
vector
- The original vectorpublic int transformX(int x, int y, int z)
x
- The x coordinate of the original vectory
- The y coordinate of the original vectorz
- The z coordinate of the original vectorpublic int transformY(com.flowpowered.math.vector.Vector3i vector)
vector
- The original vectorpublic int transformY(int x, int y, int z)
x
- The x coordinate of the original vectory
- The y coordinate of the original vectorz
- The z coordinate of the original vectorpublic int transformZ(com.flowpowered.math.vector.Vector3i vector)
vector
- The original vectorpublic int transformZ(int x, int y, int z)
x
- The x coordinate of the original vectory
- The y coordinate of the original vectorz
- The z coordinate of the original vectorpublic DiscreteTransform3 invert()
public DiscreteTransform3 compose(DiscreteTransform3 that)
that
- The transform to compose withpublic DiscreteTransform3 andThen(DiscreteTransform3 that)
that
- The transform to compose withpublic DiscreteTransform3 withTranslation(com.flowpowered.math.vector.Vector3i vector)
vector
- The translation vectorpublic DiscreteTransform3 withTranslation(int x, int y, int z)
x
- The x coordinate of the translationy
- The y coordinate of the translationz
- The z coordinate of the translationpublic DiscreteTransform3 withScale(int a)
a
- The scale factorpublic DiscreteTransform3 withScale(com.flowpowered.math.vector.Vector3i vector)
vector
- The scale vectorpublic DiscreteTransform3 withScale(int x, int y, int z)
x
- The scale factor on xy
- The scale factor on yz
- The scale factor on zpublic DiscreteTransform3 withRotation(int quarterTurns, Axis axis)
quarterTurns * 90
.
The rotation is around the block center, not the corner.quarterTurns
- The number of quarter turns in this rotationaxis
- The axis to rotate aroundpublic DiscreteTransform3 withRotation(int quarterTurns, Axis axis, com.flowpowered.math.vector.Vector3i point, boolean blockCorner)
quarterTurns * 90
. The block corner flag changes
the point to be the block upper corner instead of the center.quarterTurns
- The number of quarter turns in this rotationaxis
- The axis to rotate aroundpoint
- The point of rotation, as block coordinatesblockCorner
- Whether or not to use the corner of the block
instead of the centerpublic DiscreteTransform3 withRotation(int halfTurns, Axis axis, com.flowpowered.math.vector.Vector3i point, boolean blockCornerX, boolean blockCornerY, boolean blockCornerZ)
halfTurns * 180
. The block corner
flags change the point to be the block corner or edge instead
of the center. When all flags are false, the center is used.
When only one is true the face traversed by the axis of flag is used.
When two are true the edge in the direction of the remaining flag
is used. When all are true the upper corner is used.halfTurns
- The number of half turns in this rotationaxis
- The axis to rotate aroundpoint
- The point of rotation, as block coordinatesblockCornerX
- Whether or not to use the corner of the block
instead of the center on the x axisblockCornerY
- Whether or not to use the corner of the block
instead of the center on the y axisblockCornerZ
- Whether or not to use the corner of the block
instead of the center on the z axispublic DiscreteTransform3 withTransformation(DiscreteTransform3 transform)
transform
- The transformation to addpublic static Optional<DiscreteTransform3> of(com.flowpowered.math.matrix.Matrix4d matrix)
matrix
- The matrix to use for the transformOptional.empty()
public static DiscreteTransform3 fromTranslation(com.flowpowered.math.vector.Vector3i vector)
vector
- The translation vectorpublic static DiscreteTransform3 fromTranslation(int x, int y, int z)
x
- The x coordinate of the translationy
- The y coordinate of the translationz
- The z coordinate of the translationpublic static DiscreteTransform3 fromScale(int a)
a
- The scale factorpublic static DiscreteTransform3 fromScale(com.flowpowered.math.vector.Vector3i vector)
vector
- The scale vectorpublic static DiscreteTransform3 fromScale(int x, int y, int z)
x
- The scale factor on xy
- The scale factor on yz
- The scale factor on zpublic static DiscreteTransform3 fromRotation(int quarterTurns, Axis axis)
quarterTurns * 90
.
The rotation is around the block center, not the corner.quarterTurns
- The number of quarter turns in this rotationaxis
- The axis to rotate aroundpublic static DiscreteTransform3 fromRotation(int quarterTurns, Axis axis, com.flowpowered.math.vector.Vector3i point, boolean blockCorner)
quarterTurns * 90
. The block corner
flag change the point to be the block corner instead of the center.quarterTurns
- The number of quarter turns in this rotationaxis
- The axis to rotate aroundpoint
- The point of rotation, as block coordinatesblockCorner
- Whether or not to use the corner of the block
instead of the centerpublic static DiscreteTransform3 fromRotation(int halfTurns, Axis axis, com.flowpowered.math.vector.Vector3i point, boolean blockCornerX, boolean blockCornerY, boolean blockCornerZ)
halfTurns * 180
. When all flags are
false, the center is used. When only one is true the face traversed
by the axis of flag is used. When two are true the edge in the
direction of the remaining flag is used. When all are true the
upper corner is used.halfTurns
- The number of half turns in this rotationaxis
- The axis to rotate aroundpoint
- The point of rotation, as block coordinatesblockCornerX
- Whether or not to use the corner of the block
instead of the center on the x axisblockCornerY
- Whether or not to use the corner of the block
instead of the center on the y axisblockCornerZ
- Whether or not to use the corner of the block
instead of the center on the z axispublic static DiscreteTransform3 rotationAroundCenter(int quarterTurns, Axis axis, com.flowpowered.math.vector.Vector3i size)
quarterTurns * 90
. Volumes with differing parities on the
axes can only be rotated by multiples of 180 degrees.quarterTurns
- The amount of quarter turns in this rotationaxis
- Axis for rotationsize
- The size of the volume to rotate