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)
Reflection(axis)
Reflection across a axis of given angle
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
Axis2D
|
Reflection axis |
required |
Examples:
Reflection around the y 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)
Initialize matrix only with reflection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
Axis2D
|
Reflection axis |
required |
Examples:
Reflection around the x axis
SetRotation(point, angle)
SetScaling(scaleX, scaleY)
SetTranslation(vec)
Initialize matrix only with translation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vec
|
Vector2D
|
Vector of translation. |
required |
Examples:
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)
Translate the matrix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vec
|
Vector2D
|
Vector of translation. |
required |
Examples:
__add__(matrix)
__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)
__imul__(matrix)
__init__
overload
__init__()
__init__(matrix)
Copy constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix2D
|
Matrix which will be copied. |
required |
__isub__(matrix)
__mul__(matrix)
__repr__()
Convert to string