com.kuka.math.geometry
Class MatrixRotation

java.lang.Object
  extended by com.kuka.math.geometry.AbstractRotation
      extended by com.kuka.math.geometry.MatrixRotation
All Implemented Interfaces:
IRotation

public final class MatrixRotation
extends AbstractRotation

Immutable representation of a spatial rotation in matrix form.


Field Summary
static MatrixRotation NONE
          Immutable MatrixRotation instance representing no rotation.
 
Method Summary
 MatrixRotation compose(MatrixRotation other)
          The effect of A.compose(B) is that of the matrix multiplication A*B.
 boolean equals(Object obj)
           
 void fillRowFirstArray(double[] elements)
          Fills a "RowFirst" representation (double[3,3]) Array "Frame33" - represented as 9 element vector.
 Matrix getMatrix()
          Returns the underlying matrix that represents this rotation.
 Vector3D getUnitVectorX()
          Returns the x unit vector after it has been rotated by this rotation.
 Vector3D getUnitVectorY()
          Returns the y unit vector after it has been rotated by this rotation.
 Vector3D getUnitVectorZ()
          Returns the z unit vector after it has been rotated by this rotation.
 int hashCode()
           
 MatrixRotation invert()
          Returns an inverted rotation, i.e. a rotation that reverses the effect of this one.
static boolean isRotationMatrix(Matrix matrix)
          Function that checks whether the given matrix is rotational matrix, i.e. it must fulfill the following conditions: equal(matrix.determinant(), 1, epsilon);
equal(matrix.transpose(), matrix.invert(), epsilon); where equal(a, b, epsilon) is an element-wise test of approximate equality (small epsilon test).
static MatrixRotation of(IRotation orig)
          Returns an immutable instance from the values of the provided rotation.
static MatrixRotation of(Matrix matrix)
          Checked creation of a MatrixRotation from a given rotation matrix.
static MatrixRotation ofUnchecked(Matrix matrix)
          Unchecked creation of a MatrixRotation from a given rotation matrix.
 double[] toRowFirstArray()
          Serialization Support Serialize the MatrixRotation to a linear 9 Vector to support "rowFirstArray" (double[3][3]) Frame33 Represenations.
 String toString()
          Returns the matrix value as a 3x3 matrix formatted in a way compatible with popular scientific numerical computing applications.
 String toString(NumberFormat fmt)
          Returns the matrix value as a 3x3 matrix formatted in a way similar to popular scientific numerical computing applications.
 
Methods inherited from class com.kuka.math.geometry.AbstractRotation
applyTo, applyTo, compose, rotationalDistanceTo, rotationTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final MatrixRotation NONE
Immutable MatrixRotation instance representing no rotation.

Method Detail

ofUnchecked

public static MatrixRotation ofUnchecked(Matrix matrix)
Unchecked creation of a MatrixRotation from a given rotation matrix. The matrix must be a rotation matrix, i.e. it must fulfill the following conditions:

equal(matrix.determinant(), 1, epsilon);
equal(matrix.transpose(), matrix.invert(), epsilon);

where equal(a, b, epsilon) is an element-wise test of approximate equality (small epsilon test).

Caution: Don't use this method unless you are absolutely sure that the matrix is a valid rotation matrix! If in doubt, use of(Matrix). It can be checked if a matrix is rotational by using isRotationMatrix(Matrix).

Parameters:
matrix - a rotation matrix. Will not be checked if matrix is rotational.
Returns:
the instance

of

public static MatrixRotation of(Matrix matrix)
Checked creation of a MatrixRotation from a given rotation matrix. The matrix must be a rotation matrix, i.e. it must fulfill the following conditions:

equal(matrix.determinant(), 1, epsilon);
equal(matrix.transpose(), matrix.invert(), epsilon);

where equal(a, b, epsilon) is an element-wise test of approximate equality (small epsilon test). The epsilon used is 1e-3.

The above conditions will be checked upon creation of the rotation.

Parameters:
matrix - a rotation matrix. Will be checked.
Returns:
the instance
Throws:
IllegalArgumentException - if the matrix is null or not a rotation matrix

of

public static MatrixRotation of(IRotation orig)
Returns an immutable instance from the values of the provided rotation.

Parameters:
orig - the instance from which to take over the rotation
Returns:
an immutable instance

isRotationMatrix

public static boolean isRotationMatrix(Matrix matrix)
Function that checks whether the given matrix is rotational matrix, i.e. it must fulfill the following conditions:

equal(matrix.determinant(), 1, epsilon);
equal(matrix.transpose(), matrix.invert(), epsilon);

where equal(a, b, epsilon) is an element-wise test of approximate equality (small epsilon test). The epsilon used is 1e-3.

Parameters:
matrix - a rotation matrix. Will be checked.
Returns:
true if the matrix is a rotational matrix (i.e. it fulfills described conditions) and false otherwise.

getMatrix

public Matrix getMatrix()
Returns the underlying matrix that represents this rotation.

Specified by:
getMatrix in interface IRotation
Specified by:
getMatrix in class AbstractRotation
Returns:
the corresponding rotation matrix.

compose

public MatrixRotation compose(MatrixRotation other)
The effect of A.compose(B) is that of the matrix multiplication A*B.

Parameters:
other - the rotation to combine with this one
Returns:
the combined matrix rotation

invert

public MatrixRotation invert()
Description copied from interface: IRotation
Returns an inverted rotation, i.e. a rotation that reverses the effect of this one.

Specified by:
invert in interface IRotation
Overrides:
invert in class AbstractRotation
Returns:
the inverted rotation.

getUnitVectorX

public Vector3D getUnitVectorX()
Returns the x unit vector after it has been rotated by this rotation. The unit vectors returned by the corresponding methods of this rotation span a right-handed orthogonal rotated coordinate system.

Returns:
x unit vector after the rotation.
See Also:
getUnitVectorY(), getUnitVectorZ()

getUnitVectorY

public Vector3D getUnitVectorY()
Returns the y unit vector after it has been rotated by this rotation. The unit vectors returned by the corresponding methods of this rotation span a right-handed orthogonal rotated coordinate system.

Returns:
y unit vector after the rotation.
See Also:
getUnitVectorX(), getUnitVectorZ()

getUnitVectorZ

public Vector3D getUnitVectorZ()
Returns the z unit vector after it has been rotated by this rotation. The unit vectors returned by the corresponding methods of this rotation span a right-handed orthogonal rotated coordinate system.

Returns:
z unit vector after the rotation.
See Also:
getUnitVectorX(), getUnitVectorY()

toRowFirstArray

public double[] toRowFirstArray()
Serialization Support Serialize the MatrixRotation to a linear 9 Vector to support "rowFirstArray" (double[3][3]) Frame33 Represenations.

Returns:
newly created 9 Element Vector (to support a row-first 3x3 Array). The sequence of the elements is [rot00, rot01, rot02, rot10, rot11, rot12, rot20,rot21,rot22].

fillRowFirstArray

public void fillRowFirstArray(double[] elements)
Fills a "RowFirst" representation (double[3,3]) Array "Frame33" - represented as 9 element vector. In contrast to @see toRowFirstArray(), the memory of the "elements" vector is already considered to be existent and of the length 9.

Parameters:
elements - - a double vector with exactly 9 Elements It will be filled with the elements of the rotation in the following sequence: [rot00, rot01, rot02, rot10, rot11, rot12, rot20,rot21,rot22]

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Returns the matrix value as a 3x3 matrix formatted in a way compatible with popular scientific numerical computing applications. The matrix values will be printed in row-first order. The numerical values will be printed in the same format as defined in Double.toString(double).

The following string can be regarded as typical:

[[0.0 0.0 -1.0]; [0.0 -1.0 0.0]; [-1.0 0.0 0.0]]

Overrides:
toString in class AbstractRotation
Returns:
a textual representation of the rotation as a 3x3 matrix

toString

public String toString(NumberFormat fmt)
Returns the matrix value as a 3x3 matrix formatted in a way similar to popular scientific numerical computing applications. The matrix values will be printed in row-first order. The numerical values will be printed using the NumberFormat.format(double) method of the given formatter.

Example: The following code snippet, used on a given MatrixRotation rot

 NumberFormat fmt = NumberFormat.getNumberInstance(Locale.US);
 fmt.setMinimumFractionDigits(1);
 fmt.setMaximumFractionDigits(3);
 System.out.println(rot.toString(fmt));
might give the following output:
 [[0.707 -0.707 0.0]; [0.707 0.707 0.0]; [0.0 0.0 1.0]]

Parameters:
fmt - the NumberFormat used to format the number values
Returns:
a textual representation of the rotation as a 3x3 matrix


Copyright © 2019. All rights reserved.