Matrix2D
Class full path: NemAll_Python_Geometry.Matrix2D
Representation class for 2D matrix
Matrix2D describes transformation (translation, rotation and scaling) of a two dimensional element
Matrix data organization in memory
|0, 1, 2|
|3, 4, 5|
|6, 7, 8|
- [0..8] indexes of array values
- 0,1, 3,4 - rotation, scaling and shrinking
- 6,7 - translation
All operations are correct only in geometry calculation context and cannot be used for calculating with regular 3x3 matrix.
Functions
AddDimension()
Create a 3D matrix from this 2D matrix
Returns:
Type | Description |
---|---|
Matrix3D
|
3D Matrix from this matrix |
Determinant()
Calculate determinant
Returns:
Type | Description |
---|---|
float
|
Determinant. |
IsIdentity()
Check to identity matrix
Returns:
Type | Description |
---|---|
bool
|
Return true when is matrix identity, otherwise false. |
Multiply(matrix)
Multiple matrix with given matrix
calling " A.Multiply(B) " is identical with " A *= B "
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix2D
|
Matrix to be multiple with |
required |
Returns:
Type | Description |
---|---|
Matrix2D
|
Product of matrices |
Reflection(axis)
Reverse()
Reverse matrix
This method provide geometrical inverse matrix and can not be used with regular inverse 3x3 matrix calculations.
Returns:
Type | Description |
---|---|
bool
|
True when operation is successful, otherwise false. |
Examples:
when reversed_matrix is the inverted matrix, this expression will return True
Rotation(point, angle)
Scaling(scaleX, scaleY)
SetIdentity()
Initialize identity matrix
SetReflection(axis)
SetRotation(point, angle)
SetScaling(scaleX, scaleY)
SetTranslation(vec)
SetValue(index, value)
Set the matrix element at a specified position
Use this method when you don't want to catch exception by operator[].
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index
|
int
|
Position index <0..9> |
required |
value
|
float
|
Value for set |
required |
Returns:
Type | Description |
---|---|
bool
|
True when operation successful (index is not out of range), otherwise false. |
Translate(vec)
__add__(matrix)
Matrix addition
Formula: Result(new matrix) = A+B A is this matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix2D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix2D
|
Addition of matrices |
__getitem__(index)
Get the matrix element at a specified position
This method is checked and throwing Geometry::Exception when index is out of range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index
|
int
|
Position index <0..9> |
required |
Returns:
Type | Description |
---|---|
float
|
Returns an element at a specified position. |
__iadd__(matrix)
Matrix addition
Formula: A += B or A = A+B A is this matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix2D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix2D
|
Addition of matrices |
__imul__(matrix)
Matrix multiplication
Formula: A = B or A = AB A is this matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix2D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix2D
|
Product of matrices |
__init__
overload
__isub__(matrix)
Matrix addition
Formula: A -= B or A = A-B A is this matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix2D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix2D
|
Addition of matrices |
__mul__(matrix)
Matrix multiplication
Formula: Result(new matrix) = A*B A is this matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix2D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix2D
|
Product of matrices |
__repr__()
Convert to string
__sub__(matrix)
Matrix addition
Formula: Result(new matrix) = A-B A is this matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix2D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix2D
|
Addition of matrices |