|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.instantreality.InstantIO.Matrix3d
public class Matrix3d
Helper class for exchanging 3x3 matrices of double values.
Matrix3d is a basic helper class for exchanging matrices of 3x3 double
values between different software components. It does
not contain any means for matrix arithmetics, only methods for
setting and getting the matrix elements. It is not meant to be used
directly by software components for matrix representation. Instead,
software components should use their own, appropriate classes for
handling matrices. Only when sending matrices to an OutSlot
,
or when receiving matrices from an InSlot
, the internal
representation of matrices should be converted to Matrix3d's. This
ensures the interoperability between different software components
that use different internal representations for matrices.
Field Summary | |
---|---|
static Matrix3d |
IDENTITY
The identity matrix. |
Constructor Summary | |
---|---|
Matrix3d(double[] matrix)
Creates a new Matrix3d object that gets initialized by a given 9 element double array representing a 3x3 matrix. |
|
Matrix3d(double m11,
double m12,
double m13,
double m21,
double m22,
double m23,
double m31,
double m32,
double m33)
Creates a new Matrix3d object that gets initialized by given 9 double values representing a 3x3 matrix. |
|
Matrix3d(Matrix3d matrix)
Constructor that initializes the components of the Matrix3d object with the elements taken from another Matrix3d object. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
Compares the matrix to another object. |
void |
get(double[] matrix)
Returns the matrix elements. |
double |
get(int index)
Returns one element of the matrix. |
java.lang.String |
toString()
Converts the matrix to a string. |
static Matrix3d |
valueOf(java.lang.String str)
Converts a string to a Matrix3d object. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Matrix3d IDENTITY
Constructor Detail |
---|
public Matrix3d(double m11, double m12, double m13, double m21, double m22, double m23, double m31, double m32, double m33)
m11
- The value at row 1, column 1 of the matrixm12
- The value at row 1, column 2 of the matrixm13
- The value at row 1, column 3 of the matrixm21
- The value at row 2, column 1 of the matrixm22
- The value at row 2, column 2 of the matrixm23
- The value at row 2, column 3 of the matrixm31
- The value at row 3, column 1 of the matrixm32
- The value at row 3, column 2 of the matrixm33
- The value at row 3, column 3 of the matrixpublic Matrix3d(double[] matrix)
matrix
- The nine components of the matrixpublic Matrix3d(Matrix3d matrix)
The following example demonstrates how to create a Matrix3d object that is an exact copy of another Matrix3d object:
Matrix3d given_mat = ...; Matrix3d mat = new Matrix3d(given_mat);
matrix
- The other matrix used to initialize the new matrix.Method Detail |
---|
public final void get(double[] matrix)
The following example extracts the translation vector from the matrix and prints it to the console:
Matrix3d mat = ...; double[] m = new double[9]; mat.get(m); double x = m[6]; double y = m[7]; System.out.println("Translation = " + x + " " + y);
matrix
- A double array that gets filled with the elements of the
matrix. This array must have at least nine elements.public final double get(int index)
The following example extracts the translation vector from the matrix and prints it to the console:
Matrix3d mat = ...; double x = mat.get(6); double y = mat.get(7); System.out.println("Translation = " + x + " " + y);
index
- The index of the element. This must be between
0 and 8, inclusively.
public final boolean equals(java.lang.Object obj)
The following example compares two matrices and prints the result to the console:
Matrix3d mat1 = ...; Matrix3d mat2 = ...; System.out.println("Matrices are the same: " + mat1.equals(mat2));
equals
in class java.lang.Object
obj
- the object to compare the matrix to
public final java.lang.String toString()
The following example prints the string representation of a Matrix3d object to the console:
Matrix3d mat = ...; System.out.println("Matrix = " + mat.toString());
toString
in class java.lang.Object
public static final Matrix3d valueOf(java.lang.String str)
The following example creates a new Matrix3d object that represents a translation of 1 unit along the x axis and 2 units along the y axis:
Matrix3d mat = Matrix3d.valueOf("1.0 0.0 0.0 0.0 1.0 0.0 1.0 2.0 1.0");
str
- The string representation of the matrix.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |