Package com.itextpdf.kernel.geom
Class Matrix
- java.lang.Object
-
- com.itextpdf.kernel.geom.Matrix
-
public class Matrix extends java.lang.Object
Keeps all the values of a 3 by 3 matrix and allows you to do some math with matrices.
-
-
Field Summary
Fields Modifier and Type Field Description static int
I11
the row=1, col=1 position ('a') in the matrix.static int
I12
the row=1, col=2 position ('b') in the matrix.static int
I13
the row=1, col=3 position (always 0 for 2-D) in the matrix.static int
I21
the row=2, col=1 position ('c') in the matrix.static int
I22
the row=2, col=2 position ('d') in the matrix.static int
I23
the row=2, col=3 position (always 0 for 2-D) in the matrix.static int
I31
the row=3, col=1 ('e', or X translation) position in the matrix.static int
I32
the row=3, col=2 ('f', or Y translation) position in the matrix.static int
I33
the row=3, col=3 position (always 1 for 2-D) in the matrix.private float[]
vals
The values inside the matrix (the identity matrix by default).
-
Constructor Summary
Constructors Constructor Description Matrix()
constructs a new Matrix with identity.Matrix(float tx, float ty)
Constructs a matrix that represents translation.Matrix(float a, float b, float c, float d, float e, float f)
Creates a Matrix with 6 specified entries.Matrix(float e11, float e12, float e13, float e21, float e22, float e23, float e31, float e32, float e33)
Creates a Matrix with 9 specified entries.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Matrix
add(Matrix arg)
Adds a matrix from this matrix and returns the results.boolean
equals(java.lang.Object obj)
Checks equality of matrices.float
get(int index)
Gets a specific value inside the matrix.float
getDeterminant()
Computes the determinant of the matrix.int
hashCode()
Generates a hash code for this object.Matrix
multiply(Matrix by)
multiplies this matrix by 'b' and returns the result.Matrix
subtract(Matrix arg)
Subtracts a matrix from this matrix and returns the results.java.lang.String
toString()
Generates a String representation of the matrix.
-
-
-
Field Detail
-
I11
public static final int I11
the row=1, col=1 position ('a') in the matrix.- See Also:
- Constant Field Values
-
I12
public static final int I12
the row=1, col=2 position ('b') in the matrix.- See Also:
- Constant Field Values
-
I13
public static final int I13
the row=1, col=3 position (always 0 for 2-D) in the matrix.- See Also:
- Constant Field Values
-
I21
public static final int I21
the row=2, col=1 position ('c') in the matrix.- See Also:
- Constant Field Values
-
I22
public static final int I22
the row=2, col=2 position ('d') in the matrix.- See Also:
- Constant Field Values
-
I23
public static final int I23
the row=2, col=3 position (always 0 for 2-D) in the matrix.- See Also:
- Constant Field Values
-
I31
public static final int I31
the row=3, col=1 ('e', or X translation) position in the matrix.- See Also:
- Constant Field Values
-
I32
public static final int I32
the row=3, col=2 ('f', or Y translation) position in the matrix.- See Also:
- Constant Field Values
-
I33
public static final int I33
the row=3, col=3 position (always 1 for 2-D) in the matrix.- See Also:
- Constant Field Values
-
vals
private final float[] vals
The values inside the matrix (the identity matrix by default).For reference, the indeces are as follows:
I11 I12 I13
I21 I22 I23
I31 I32 I33
-
-
Constructor Detail
-
Matrix
public Matrix()
constructs a new Matrix with identity.
-
Matrix
public Matrix(float tx, float ty)
Constructs a matrix that represents translation.- Parameters:
tx
- x-axis translationty
- y-axis translation
-
Matrix
public Matrix(float e11, float e12, float e13, float e21, float e22, float e23, float e31, float e32, float e33)
Creates a Matrix with 9 specified entries.- Parameters:
e11
- element at position (1,1)e12
- element at position (1,2)e13
- element at position (1,3)e21
- element at position (2,1)e22
- element at position (2,2)e23
- element at position (2,3)e31
- element at position (3,1)e32
- element at position (3,2)e33
- element at position (3,3)
-
Matrix
public Matrix(float a, float b, float c, float d, float e, float f)
Creates a Matrix with 6 specified entries. The third column will always be [0 0 1] (row, column)- Parameters:
a
- element at (1,1)b
- element at (1,2)c
- element at (2,1)d
- element at (2,2)e
- element at (3,1)f
- element at (3,2)
-
-
Method Detail
-
get
public float get(int index)
Gets a specific value inside the matrix.For reference, the indeces are as follows:
I11 I12 I13
I21 I22 I23
I31 I32 I33- Parameters:
index
- an array index corresponding with a value inside the matrix- Returns:
- the value at that specific position.
-
multiply
public Matrix multiply(Matrix by)
multiplies this matrix by 'b' and returns the result. See http://en.wikipedia.org/wiki/Matrix_multiplication- Parameters:
by
- The matrix to multiply by- Returns:
- the resulting matrix
-
add
public Matrix add(Matrix arg)
Adds a matrix from this matrix and returns the results.- Parameters:
arg
- the matrix to subtract from this matrix- Returns:
- a Matrix object
-
subtract
public Matrix subtract(Matrix arg)
Subtracts a matrix from this matrix and returns the results.- Parameters:
arg
- the matrix to subtract from this matrix- Returns:
- a Matrix object
-
getDeterminant
public float getDeterminant()
Computes the determinant of the matrix.- Returns:
- the determinant of the matrix
-
equals
public boolean equals(java.lang.Object obj)
Checks equality of matrices.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the other Matrix that needs to be compared with this matrix.- Returns:
- true if both matrices are equal
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
Generates a hash code for this object.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hash code of this object
- See Also:
Object.hashCode()
-
toString
public java.lang.String toString()
Generates a String representation of the matrix.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the values, delimited with tabs and newlines.
- See Also:
Object.toString()
-
-