Class Transformation3D
- All Implemented Interfaces:
Showable
Transformable
interface.
To use Transformation3D
object to rotate and translate a
Transformable
object, use the apply(org.jlab.geom.prim.Transformable)
method.
If a Transformation3D
object is constructed with no arguments, then
it will contain no transformations and will in essence represent an identity
transformation aka do-nothing transformation.
The translateXYZ(double, double, double)
, rotateX(double)
,
rotateY(double)
, rotateZ(double)
, and
append(Transformation3D)
methods all modify the object from which
they are invoked, but these functions also return a copy of the object so
that rotations and translations can be chained together and written on a
single line.
Ex.
Transformation3D() xform = new Transformation3D(); // identity
xform.translateXYZ(100, 0, 20).rotateZ(Math.PI);
In this example, after the code has executed xform
will be a
transformation that first translates an object by x+100 and z+20, and then
rotates the object by 180 degrees clockwise around the z-axis.
The inverse of a transformation can be obtained via inverse()
.
Ex.
Transformation3D inv = xform.inverse();
Point3D pt = new Point3D(3, 5, 7);
xform.apply(pt);
inv.apply(pt);
At the end of this example, pt
should equal to (3, 5, 7), however
extremely small rounding errors may be introduced due to the nature of
floating point arithmetic (but no more than 1 ulp per coordinate per
transformation).
- Author:
- jnhankins
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A clockwise rotation around the x-axis.static class
A clockwise rotation around the y-axis.static class
A clockwise rotation around the z-axis.static interface
A interface for geometric transformations (eg translations and rotations) that can be applied to aTransformable
object.static class
A translation transformation. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new emptyTransformation3D
that is equivalent to an identity transformation.Transformation3D
(Transformation3D transform) Constructs a newTransformation3D
identical the the given transformation. -
Method Summary
Modifier and TypeMethodDescriptionappend
(Transformation3D transformation) Appends a copy of the given transformation to this transformation.append
(Transformation3D.Transform trans) Appends the given apply to this transformation.void
apply
(Transformable obj) Modifies the givenTransformable
object by applying the transformation represented by thisTransformation3D
to the given object.void
clear()
Resets this transformation by removing all of its transforms.copy
(Transformation3D transform) Sets this transformation to be equal to the given transformation.inverse()
Constructs a newTransformation3D
that is the inverse of this transformation.rotateX
(double angle) Appends a clockwise rotation around the x axis to this transformation.rotateY
(double angle) Appends a clockwise rotation around the y axis to this transformation.rotateZ
(double angle) Appends a clockwise rotation around the z axis to this transformation.void
show()
InvokesSystem.out.println(this)
.toString()
Returns a reference to thisTransformation3D
'sTransform
sequence.translateXYZ
(double dx, double dy, double dz) Appends a translation to this transformation.
-
Constructor Details
-
Method Details
-
copy
Sets this transformation to be equal to the given transformation.- Parameters:
transform
- the transformation to copy- Returns:
- a reference to this object
-
translateXYZ
Appends a translation to this transformation.- Parameters:
dx
- amount to translate along the x axisdy
- amount to translate along the y axisdz
- amount to translate along the z axis- Returns:
- a reference to this object
-
rotateX
Appends a clockwise rotation around the x axis to this transformation.- Parameters:
angle
- rotation angle in radians- Returns:
- a reference to this object
-
rotateY
Appends a clockwise rotation around the y axis to this transformation.- Parameters:
angle
- rotation angle in radians- Returns:
- a reference to this object
-
rotateZ
Appends a clockwise rotation around the z axis to this transformation.- Parameters:
angle
- rotation angle in radians- Returns:
- a reference to this object
-
append
Appends the given apply to this transformation.- Parameters:
trans
- the apply to append- Returns:
- a reference to this object
-
append
Appends a copy of the given transformation to this transformation.- Parameters:
transformation
- the transformation append- Returns:
- a reference to this object
-
apply
Modifies the givenTransformable
object by applying the transformation represented by thisTransformation3D
to the given object.- Parameters:
obj
- the object to apply this transformation to
-
clear
public void clear()Resets this transformation by removing all of its transforms. -
inverse
Constructs a newTransformation3D
that is the inverse of this transformation.- Returns:
- the inverse of this transformation
-
transformSequence
Returns a reference to thisTransformation3D
'sTransform
sequence. Modifying the returned list will modify thisTransformation3D
.- Returns:
- the transform sequence
-
show
-
toString
-