Interface Transform
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTransform.Factory
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Transformadd(Transform other)"Adds" another transform to this one.static Transformof(Vector3d position)static Transformof(Vector3d position, Vector3d rotation)static Transformof(Vector3d position, Vector3d rotation, Vector3d scale)doublepitch()Gets the pitch component of this transform rotation.Vector3dposition()Gets the coordinates of this transform.doubleroll()Gets the roll component of this transform rotation.Transformrotate(Quaterniond rotation)Adds a rotation to this transform.Transformrotate(Vector3d rotation)Adds a rotation to this transform.Vector3drotation()Gets the rotation of this transform, as aVector3d.QuaterniondrotationAsQuaternion()Returns the rotation as a quaternion.Vector3dscale()Gets the scale of the transform for each axis.Transformscale(Vector3d scale)"Adds" a scale to this transform.Matrix4dtoMatrix()Returns a matrix representation of this transform.Transformtranslate(Vector3d translation)Adds a translation to this transform.TransformwithPosition(Vector3d position)Creates a copy of this transform while setting the position of the new one.TransformwithRotation(Quaterniond rotation)Creates a copy of this transform and sets the rotation.TransformwithRotation(Vector3d rotation)Creates a copy of this transform and sets the rotation as a quaternion.TransformwithScale(Vector3d scale)Creates a copy of this transform and sets the scale for each axis.doubleyaw()Gets the yaw component of this transform rotation.
-
-
-
Method Detail
-
position
Vector3d position()
Gets the coordinates of this transform.- Returns:
- The coordinates
-
withPosition
Transform withPosition(Vector3d position)
Creates a copy of this transform while setting the position of the new one.- Parameters:
position- The position- Returns:
- A new transform
-
rotation
Vector3d rotation()
Gets the rotation of this transform, as aVector3d.The format of the rotation is represented by:
x -> pitchy -> yawz -> roll
- Returns:
- The rotation vector
-
withRotation
Transform withRotation(Vector3d rotation)
Creates a copy of this transform and sets the rotation as a quaternion.Quaternions are objectively better than the Euler angles preferred by Minecraft. This is for compatibility with the flow-math library.
- Parameters:
rotation- The new rotation- Returns:
- A new transform
-
withRotation
Transform withRotation(Quaterniond rotation)
Creates a copy of this transform and sets the rotation.The format of the rotation is represented by:
x -> pitchy -> yawz -> roll
- Parameters:
rotation- The new rotation- Returns:
- A new transform
-
rotationAsQuaternion
Quaterniond rotationAsQuaternion()
Returns the rotation as a quaternion.Quaternions are objectively better than the Euler angles preferred by Minecraft. This is for compatibility with the flow-math library.
- Returns:
- The rotation
-
pitch
double pitch()
Gets the pitch component of this transform rotation.- Returns:
- The pitch
-
yaw
double yaw()
Gets the yaw component of this transform rotation.- Returns:
- The yaw
-
roll
double roll()
Gets the roll component of this transform rotation.- Returns:
- The roll
-
scale
Vector3d scale()
Gets the scale of the transform for each axis.- Returns:
- The scale
-
withScale
Transform withScale(Vector3d scale)
Creates a copy of this transform and sets the scale for each axis.- Parameters:
scale- The scale- Returns:
- A new transform
-
add
Transform add(Transform other)
"Adds" another transform to this one. This is equivalent to adding the translation, rotation and scale individually.Returns the results as a new copy.
- Parameters:
other- The transform to add- Returns:
- A new transform
-
translate
Transform translate(Vector3d translation)
Adds a translation to this transform.Returns the results as a new copy.
- Parameters:
translation- The translation to add- Returns:
- A new transform
-
rotate
Transform rotate(Vector3d rotation)
Adds a rotation to this transform. Returns the results as a new copy.- Parameters:
rotation- The rotation to add- Returns:
- A new transform
-
rotate
Transform rotate(Quaterniond rotation)
Adds a rotation to this transform.Quaternions are objectively better than the Euler angles preferred by Minecraft. This is the preferred method when dealing with rotation additions. This is for compatibility with the flow-math library.
Returns the results as a new copy.
- Parameters:
rotation- The rotation to add- Returns:
- A new transform
-
scale
Transform scale(Vector3d scale)
"Adds" a scale to this transform. Scales are multiplicative, so this actually multiplies the current scale.Returns the results as a new copy.
- Parameters:
scale- The scale to add- Returns:
- A new transform
-
toMatrix
Matrix4d toMatrix()
Returns a matrix representation of this transform.This includes the position, rotation and scale. To apply the transform to a vector, use the following:
Vector3d original = ...;<br /> Transform transform = ...;<br /><br /> Vector3d transformed = transform.toMatrix().transform(original.toVector4(1)).toVector3();<br />}This converts the original 3D vector to 4D by appending 1 as the w coordinate, applies the transformation, then converts it back to 3D by dropping the w coordinate.
Using a 4D matrix and a w coordinate with value 1 is what allows for the position to be included in the transformation applied by the matrix.
- Returns:
- The transform as a matrix
-
-