Package eu.svjatoslav.sixth.e3d.math
Class Transform
java.lang.Object
eu.svjatoslav.sixth.e3d.math.Transform
- All Implemented Interfaces:
Cloneable
Represents a transformation in 3D space combining translation and rotation.
Transformations are applied in order: rotation first, then translation.
Mutability convention:
- Imperative verbs (
set,setTranslation,transform) mutate this transform or the input point with-prefixed methods (withTransformed) return a new instance without modifying the original
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a transform with no translation or rotation (identity transform).Creates a transform with the specified translation and no rotation.Transform(Point3D translation, Quaternion rotation) Creates a transform with the specified translation and rotation. -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a copy of this transform with cloned translation and rotation.static TransformfromAngles(double x, double y, double z, double yaw, double pitch, double roll) Creates a transform with translation and full Euler rotation.static TransformfromAngles(Point3D translation, double yaw, double pitch) Creates a transform with the specified translation and rotation from Euler angles.Returns the rotation component of this transform.Returns the translation component of this transform.set(double x, double y, double z, double yaw, double pitch, double roll) Sets both translation and rotation from Euler angles.setTranslation(Point3D translation) Sets the translation for this transform by copying the values from the given point.voidApplies this transform to a point: rotation followed by translation.withTransformed(Point3D point) Returns a new point with this transform applied.
-
Constructor Details
-
Transform
public Transform()Creates a transform with no translation or rotation (identity transform). -
Transform
Creates a transform with the specified translation and no rotation.- Parameters:
translation- the translation
-
Transform
Creates a transform with the specified translation and rotation.- Parameters:
translation- the translationrotation- the rotation (will be cloned)
-
-
Method Details
-
fromAngles
Creates a transform with the specified translation and rotation from Euler angles.- Parameters:
translation- the translationyaw- the angle around the Y axis (horizontal heading) in radianspitch- the angle around the X axis (vertical tilt) in radians- Returns:
- a new transform with the specified translation and rotation
-
fromAngles
public static Transform fromAngles(double x, double y, double z, double yaw, double pitch, double roll) Creates a transform with translation and full Euler rotation.Rotation order: yaw (Y) → pitch (X) → roll (Z). This is the standard Y-X-Z Euler order commonly used for object placement in 3D scenes.
- Parameters:
x- translation X coordinatey- translation Y coordinatez- translation Z coordinateyaw- rotation around Y axis (horizontal heading) in radianspitch- rotation around X axis (vertical tilt) in radiansroll- rotation around Z axis (bank/tilt) in radians- Returns:
- a new transform with the specified translation and rotation
-
clone
Creates a copy of this transform with cloned translation and rotation. -
getRotation
Returns the rotation component of this transform.- Returns:
- the rotation quaternion (mutable reference)
-
getTranslation
Returns the translation component of this transform.- Returns:
- the translation point (mutable reference)
-
transform
Applies this transform to a point: rotation followed by translation.- Parameters:
point- the point to transform (modified in place)- See Also:
-
withTransformed
Returns a new point with this transform applied. The original point is not modified.- Parameters:
point- the point to transform- Returns:
- a new Point3D with the transform applied
- See Also:
-
setTranslation
Sets the translation for this transform by copying the values from the given point.- Parameters:
translation- the translation values to copy- Returns:
- this transform (for chaining)
-
set
Sets both translation and rotation from Euler angles.Rotation order: yaw (Y) → pitch (X) → roll (Z). This is the standard Y-X-Z Euler order commonly used for object placement in 3D scenes.
- Parameters:
x- translation X coordinatey- translation Y coordinatez- translation Z coordinateyaw- rotation around Y axis (horizontal heading) in radianspitch- rotation around X axis (vertical tilt) in radiansroll- rotation around Z axis (bank/tilt) in radians- Returns:
- this transform for chaining
-