Class Transform3D

  • All Implemented Interfaces:
    Serializable, Cloneable

    public class Transform3D
    extends Matrix4d
    A 3D transformation. Is represented internally as a 4x4 floating point matrix. The mathematical representation is row major, as in traditional matrix mathematics.

    The transformation matrix is:

    
     | r11 | r12 | r13 | Tx |
     | r21 | r22 | r23 | Ty |
     | r31 | r32 | r33 | Tz |
     | 0   | 0   | 0   | 1  |
     
    Since:
    13.0
    Version:
    17.0 2020-01-04 14:41:43
    Author:
    Thomas PIOTROWSKI, Stéphane GALLAND
    See Also:
    Serialized Form
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    mathgeom
    • Field Detail

      • IDENTITY

        public static final Transform3D IDENTITY
        This is the identifity transformation.
    • Constructor Detail

      • Transform3D

        public Transform3D()
        Constructs a new Transform3D object and sets it to the identity transformation.
      • Transform3D

        public Transform3D​(double m00,
                           double m01,
                           double m02,
                           double m03,
                           double m10,
                           double m11,
                           double m12,
                           double m13,
                           double m20,
                           double m21,
                           double m22,
                           double m23)
        Constructs and initializes a Matrix4f from the specified nine values.
        Parameters:
        m00 - the [0][0] element
        m01 - the [0][1] element
        m02 - the [0][2] element
        m03 - the [0][3] element
        m10 - the [1][0] element
        m11 - the [1][1] element
        m12 - the [1][2] element
        m13 - the [1][3] element
        m20 - the [2][0] element
        m21 - the [2][1] element
        m22 - the [2][2] element
        m23 - the [2][3] element
      • Transform3D

        public Transform3D​(Transform3D transform)
        Constructs a new Transform2D object and initializes it from the specified transform.
        Parameters:
        transform - the transformation to copy.
      • Transform3D

        public Transform3D​(Matrix4d matrix)
        Constructor by copy.
        Parameters:
        matrix - the matrix to copy.
    • Method Detail

      • clone

        @Pure
        public Transform3D clone()
        Description copied from class: Matrix4d
        Creates a new object of the same class as this object.
        Overrides:
        clone in class Matrix4d
        Returns:
        a clone of this instance.
        See Also:
        Cloneable
      • setTranslation

        public void setTranslation​(double x,
                                   double y,
                                   double z)
        Set the position.

        This function changes only the elements of the matrix related to the translation. The scaling and the shearing are not changed.

        After a call to this function, the matrix will contains (? means any value):

                  [   ?    ?    x   ]
                  [   ?    ?    y   ]
                  [   ?    ?    z   ]
                  [   ?    ?    ?   ]
         
        Parameters:
        x - x translation.
        y - y translation.
        z - z translation.
        See Also:
        makeTranslationMatrix(double, double, double)
      • setTranslation

        public void setTranslation​(Tuple3D<?> translation)
        Set the position.

        This function changes only the elements of the matrix related to the translation. The scaling and the shearing are not changed.

        After a call to this function, the matrix will contains (? means any value):

                  [   ?    ?    t.x   ]
                  [   ?    ?    t.y   ]
                  [   ?    ?    t.z   ]
                  [   ?    ?    ?     ]
         
        Parameters:
        translation - the translation
        See Also:
        makeTranslationMatrix(double, double, double)
      • translate

        public void translate​(double dx,
                              double dy,
                              double dz)
        Translate the position.

        This function is equivalent to:

         this = this *  [   0    0    0    dx   ]
                        [   0    0    0    dy   ]
                        [   0    0    0    dz   ]
                        [   0    0    0    1    ]
         
        Parameters:
        dx - the x translation
        dy - the y translation
        dz - the z translation
      • translate

        public void translate​(Vector3D<?,​?> translation)
        Translate the position.

        This function is equivalent to:

         this = this *  [   0    0    0    t.x   ]
                        [   0    0    0    t.y   ]
                        [   0    0    0    t.z   ]
                        [   0    0    0    1     ]
         
        Parameters:
        translation - the translation
      • getTranslationX

        @Pure
        public double getTranslationX()
        Replies the X translation.
        Returns:
        the amount
      • getTranslationY

        @Pure
        public double getTranslationY()
        Replies the Y translation.
        Returns:
        the amount
      • getTranslationZ

        @Pure
        public double getTranslationZ()
        Replies the Z translation.
        Returns:
        the amount
      • setRotation

        public void setRotation​(Quaternion rotation)
        Set the rotation for the object but do not change the translation.

        This function changes only the elements of the matrix related to the rotation. The translation is not changed.

        After a call to this function, the matrix will contains (? means any value, and r is the translation of the quaternion as a 3x3 matrix):

                  [   r   r   r   ?   ]
                  [   r   r   r   ?   ]
                  [   r   r   r   ?   ]
                  [   ?   ?   ?   ?   ]
         
        Parameters:
        rotation - the rotation
        See Also:
        makeRotationMatrix(Quaternion)
      • setRotation

        public void setRotation​(double angle)
        Set this transform's rotation.
        Parameters:
        angle - the rotation angle.
      • rotate

        public void rotate​(Quaternion rotation)
        Rotate the object.

        This function is equivalent to (where r is the translation of the quaternion as a 3x3 matrix):

         this = this *  [   r    r     r     0   ]
                        [   r    r     r     0   ]
                        [   r    r     r     0   ]
                        [   0    0     0     1   ]
         
        Parameters:
        rotation - the rotationi
      • makeRotationMatrix

        public final void makeRotationMatrix​(Quaternion rotation)
        Sets the value of this matrix to a rotation matrix, and no translation.

        This function changes all the elements of the matrix, including the translation.

        After a call to this function, the matrix will contains (? means any value, and r a value from the quaternion):

                  [   r  r  r  0   ]
                  [   r  r  r  0   ]
                  [   r  r  r  0   ]
                  [   0  0  0  1   ]
         
        Parameters:
        rotation - the rotation
        See Also:
        setRotation(Quaternion)
      • makeRotationMatrix

        public void makeRotationMatrix​(double angle)
        Sets the value of this matrix to a rotation matrix, and no translation.
        Parameters:
        angle - the angle of the rotation
      • makeTranslationMatrix

        public final void makeTranslationMatrix​(double dx,
                                                double dy,
                                                double dz)
        Sets the value of this matrix to the given translation, without rotation.

        This function changes all the elements of the matrix including the scaling and the shearing.

        After a call to this function, the matrix will contains (? means any value):

                  [   1    0    0    dx   ]
                  [   0    1    0    dy   ]
                  [   0    0    1    dz   ]
                  [   0    0    0    1    ]
         
        Parameters:
        dx - is the position to put in the matrix.
        dy - is the position to put in the matrix.
        dz - is the position to put in the matrix.
        See Also:
        setTranslation(double, double, double), setTranslation(Tuple3D)
      • transform

        public void transform​(Tuple3D<?> t)
        Multiply this matrix by the tuple t and place the result back into the tuple (t = this*t).
        Parameters:
        t - the tuple to be multiplied by this matrix and then replaced
      • transform

        public void transform​(Tuple3D<?> t,
                              Tuple3D<?> result)
        Multiply this matrix by the tuple t and and place the result into the tuple "result" (result = this*t).
        Parameters:
        t - the tuple to be multiplied by this matrix
        result - the tuple into which the product is placed
      • set

        public void set​(double m00,
                        double m01,
                        double m02,
                        double m03,
                        double m10,
                        double m11,
                        double m12,
                        double m13,
                        double m20,
                        double m21,
                        double m22,
                        double m23)
        Set the components of the transformation.
        Parameters:
        m00 - the [0][0] element
        m01 - the [0][1] element
        m02 - the [0][2] element
        m03 - the [0][3] element
        m10 - the [1][0] element
        m11 - the [1][1] element
        m12 - the [1][2] element
        m13 - the [1][3] element
        m20 - the [2][0] element
        m21 - the [2][1] element
        m22 - the [2][2] element
        m23 - the [2][3] element