Interface Transformation
-
public interface Transformation
Performs spacial transformations on position and directionVector3d
s, for general use in block transformations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Transformation.Builder
Createstransformations
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static Transformation.Builder
builder()
Gets aTransformation.Builder
for creating transformations.Matrix4d
directionTransformationMatrix()
Gets thematrix
used to perform this transformation on direction vectors.boolean
initialMirror(Axis axis)
Returns the direction of mirroring in this transformation, if mirroring was performed before rotation, at the point before the mirroring occurs.Transformation
inverse()
Gets theTransformation
that reverses this transformation.boolean
mirror(Axis axis)
Returns whether this transformation results in mirroring in the direction of the provided axis.Vector3d
origin()
Gets the origin of the position transformation matrix.boolean
performsRounding()
If this istrue
, then this transformation will attempt to round the result to reduce the effects of machine precision, which may be particularly useful for those who expect integer values.Matrix4d
positionTransformationMatrix()
Gets thematrix
used to perform this transformation on position vectors.Rotation
rotation()
Gets theRotation
around the y-axisTransformation
then(Transformation transformation)
Returns are new Transformation which represents the combination of this transformation, followed by the supplied transformation.Transformation.Builder
toBuilder()
Creates aTransformation.Builder
that represents this transformation.Vector3d
transformDirection(Vector3d originalDirection)
Transforms aVector3d
that represents a direction based on the transformation this object represents.Vector3d
transformPosition(Vector3d original)
Transforms aVector3d
that represents a position based on the transformation this object represents.
-
-
-
Method Detail
-
builder
static Transformation.Builder builder()
Gets aTransformation.Builder
for creating transformations.- Returns:
- A builder
-
transformPosition
Vector3d transformPosition(Vector3d original)
Transforms aVector3d
that represents a position based on the transformation this object represents.- Parameters:
original
- The position vector to transform- Returns:
- The transformed position vector
-
transformDirection
Vector3d transformDirection(Vector3d originalDirection)
Transforms aVector3d
that represents a direction based on the transformation this object represents.Specifically, this transformation will not apply any translational transformations.
- Parameters:
originalDirection
- The direction vector to transform- Returns:
- The transformed direction vector
-
positionTransformationMatrix
Matrix4d positionTransformationMatrix()
Gets thematrix
used to perform this transformation on position vectors.- Returns:
- The
Matrix4d
-
directionTransformationMatrix
Matrix4d directionTransformationMatrix()
Gets thematrix
used to perform this transformation on direction vectors.- Returns:
- The
Matrix4d
-
origin
Vector3d origin()
Gets the origin of the position transformation matrix.- Returns:
- The origin of the position transformations
-
mirror
boolean mirror(Axis axis)
Returns whether this transformation results in mirroring in the direction of the provided axis.This represents any mirroring that would need to occur after any rotation has occurred. If you require knowing what the mirror state would be pre-rotation, use
initialMirror(Axis)
instead.- Parameters:
axis
- TheAxis
- Returns:
- true if so
-
initialMirror
boolean initialMirror(Axis axis)
Returns the direction of mirroring in this transformation, if mirroring was performed before rotation, at the point before the mirroring occurs. The axis is in the direction of the mirroring.Unlike
mirror(Axis)
, which provides a view to the direction(s) of mirroring after all transformations have taken place, this method returns the direction of mirroring before any rotation has taken place, such that if therotation()
was set toRotations.NONE
, this would be the direction of mirroring.- Parameters:
axis
- TheAxis
- Returns:
- true if so
-
inverse
Transformation inverse()
Gets theTransformation
that reverses this transformation.- Returns:
- The inverse transformation
-
performsRounding
boolean performsRounding()
If this istrue
, then this transformation will attempt to round the result to reduce the effects of machine precision, which may be particularly useful for those who expect integer values.The rounding should be on the order of 15 decimal places, though other implementations may choose more sophisticated rounding.
- Returns:
- Whether the result will have minor rounding applied.
-
toBuilder
Transformation.Builder toBuilder()
Creates aTransformation.Builder
that represents this transformation.- Returns:
- The builder.
-
then
Transformation then(Transformation transformation)
Returns are new Transformation which represents the combination of this transformation, followed by the supplied transformation.You must not assume that the second transformation origin is relative to the first. Each transformation is assumed to operate in untransformed and each is assumed to operate around the origin specified in that transformation. For example, if the first transformation operates around (1, 1, 1), and the second operates around (2, 2, 2), this will still be the case, the second won't operate around (3, 3, 3). As a result,
origin()
will returnVector3d.ZERO
unless the two origins are equal to each other.The resultant transformation will set
performsRounding()
to the value of this transformation.- Parameters:
transformation
- The transformation to perform after this one- Returns:
- A new, combined, transformation
-
-