Interface Transformation
-
public interface TransformationPerforms spacial transformations on position and directionVector3ds, for general use in block transformations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTransformation.BuilderCreatestransformations.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static Transformation.Builderbuilder()Gets aTransformation.Builderfor creating transformations.Matrix4ddirectionTransformationMatrix()Gets thematrixused to perform this transformation on direction vectors.booleaninitialMirror(Axis axis)Returns the direction of mirroring in this transformation, if mirroring was performed before rotation, at the point before the mirroring occurs.Transformationinverse()Gets theTransformationthat reverses this transformation.booleanmirror(Axis axis)Returns whether this transformation results in mirroring in the direction of the provided axis.Vector3dorigin()Gets the origin of the position transformation matrix.booleanperformsRounding()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.Matrix4dpositionTransformationMatrix()Gets thematrixused to perform this transformation on position vectors.Rotationrotation()Gets theRotationaround the y-axisTransformationthen(Transformation transformation)Returns are new Transformation which represents the combination of this transformation, followed by the supplied transformation.Transformation.BuildertoBuilder()Creates aTransformation.Builderthat represents this transformation.Vector3dtransformDirection(Vector3d originalDirection)Transforms aVector3dthat represents a direction based on the transformation this object represents.Vector3dtransformPosition(Vector3d original)Transforms aVector3dthat represents a position based on the transformation this object represents.
-
-
-
Method Detail
-
builder
static Transformation.Builder builder()
Gets aTransformation.Builderfor creating transformations.- Returns:
- A builder
-
transformPosition
Vector3d transformPosition(Vector3d original)
Transforms aVector3dthat 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 aVector3dthat 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 thematrixused to perform this transformation on position vectors.- Returns:
- The
Matrix4d
-
directionTransformationMatrix
Matrix4d directionTransformationMatrix()
Gets thematrixused 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 theTransformationthat 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.Builderthat 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.ZEROunless 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
-
-