Matrix3D
Class full path: NemAll_Python_Geometry.Matrix3D
Representation class for 3D matrix
Matrix data organization in memory: [0..15] indexes of array values 0,1,2, 4,5,6, 8,9,10 - rotation, scaling and shrinking 12,13,14 - translatio
0, 1, 2, 3 4, 5, 6, 7 8, 9, 10,11 12,13,14,15
All operations are correct only in geometry calculation context and can not be used for calculating with regular 4x4 matrix.
Functions
Determinant()
Calculate determinant
Returns:
Type | Description |
---|---|
float
|
Determinant. |
GaussInvert()
Inverse matrix by Gauss
Returns:
Type | Description |
---|---|
bool
|
True when operation is successful, otherwise false. |
GetScaleX()
Get scale X
Returns:
Type | Description |
---|---|
float
|
scale X |
GetScaleY()
Get scale Y
Returns:
Type | Description |
---|---|
float
|
scale Y |
GetScaleZ()
Get scale Z
Returns:
Type | Description |
---|---|
float
|
scale Z |
GetScaling()
Calculates the scaling factors from the matrix
Returns:
Type | Description |
---|---|
float
|
tuple(Scale in X axis, |
float
|
Scale in Y axis, |
float
|
Scale in Z axis) |
GetTranslationVector()
Get translation part of a matrix
Returns:
Type | Description |
---|---|
Vector3D
|
The vector of translation |
GetVectorX()
Get vector X
Returns:
Type | Description |
---|---|
Vector3D
|
Vector X |
GetVectorY()
Get vector Y
Returns:
Type | Description |
---|---|
Vector3D
|
Vector Y |
GetVectorZ()
Get vector Z
Returns:
Type | Description |
---|---|
Vector3D
|
Vector Z |
IsIdentity()
Check to identity matrix
Returns:
Type | Description |
---|---|
bool
|
Return true when is matrix identity, otherwise false. |
LaplaceTransform()
Transformation matrix by Laplace
Multiply(matrix)
Matrix multiplication
Formula: A = B or A = AB A is this matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix3D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix3D
|
Product of matrices |
ReduceZDimension()
Create a 2D matrix from this 3D matrix
Returns:
Type | Description |
---|---|
Matrix2D
|
a 2D matrix from this 3D matrix |
Reflection(plane)
Reflection across a plane
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plane
|
Plane3D
|
Reflection plane |
required |
Reverse()
Reverse matrix
This method provide geometrical inverse matrix and can not be used with regular inverse 4x4 matrix calculations.
Geometrical representation: Point3D = { Point3D * Matrix } * Matrix.Reverse()
Returns:
Type | Description |
---|---|
bool
|
True when operation is successful, otherwise false. |
Rotation(line, angle)
Rotate the matrix
Rotate current matrix, not created new one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
line
|
Line3D
|
Axis of rotation. |
required |
angle
|
Angle
|
Angle of rotation. |
required |
Returns:
Type | Description |
---|---|
bool
|
True when successful, otherwise false. |
Scaling(scaleX, scaleY, scaleZ)
Scale the matrix
Scale current matrix, not created new one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scaleX
|
float
|
Scale in X axis. |
required |
scaleY
|
float
|
Scale in Y axis. |
required |
scaleZ
|
float
|
Scale in Z axis. |
required |
SetIdentity()
Initialize identity matrix
SetProjection(proj)
Create a matrix for the required projection
Method throw THROW_GEO_EXCEPTION_INCORRECT_PARAMETERS_ geometry exception in case of invalid proj.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
proj
|
eProjectionMatrixType
|
The required projection |
required |
SetReflection(plane)
Initialize matrix only with reflection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plane
|
Plane3D
|
Reflection plane |
required |
SetRotation
overload
SetRotation(axis, angle)
Initialize matrix only with rotation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis
|
Line3D
|
Axis of rotation. |
required |
angle
|
Angle
|
Angle of rotation. |
required |
Returns:
Type | Description |
---|---|
bool
|
True when successful, otherwise false. |
SetRotation(startDirection, endDirection)
Initialize matrix only with rotation defined by start and end direction vectors
Parameters:
Name | Type | Description | Default |
---|---|---|---|
startDirection
|
Vector3D
|
direction vector for start of rotation. |
required |
endDirection
|
Vector3D
|
direction vector for end of rotation. |
required |
Returns:
Type | Description |
---|---|
bool
|
True when successful, otherwise false. |
SetScaling(scaleX, scaleY, scaleZ)
Initialize matrix only with scaling factors
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scaleX
|
float
|
Scale in X axis. |
required |
scaleY
|
float
|
Scale in Y axis. |
required |
scaleZ
|
float
|
Scale in Z axis. |
required |
SetTranslation(vec)
Initialize matrix only with translation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vec
|
Vector3D
|
Vector of translation. |
required |
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..15> |
required |
value
|
float
|
Value for set |
required |
Returns:
Type | Description |
---|---|
bool
|
True when operation successful (index is not out of range), otherwise false. |
SetValues(v00, v01, v02, v03, v10, v11, v12, v13, v20, v21, v22, v23, v30, v31, v32, v33)
Sets each matrix-element
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v00
|
float
|
first row, first element |
required |
v01
|
float
|
first row, second element |
required |
v02
|
float
|
first row, third element |
required |
v03
|
float
|
first row, fourth element |
required |
v10
|
float
|
second row, first element |
required |
v11
|
float
|
second row, second element |
required |
v12
|
float
|
second row, third element |
required |
v13
|
float
|
second row, fourth element |
required |
v20
|
float
|
third row, first element |
required |
v21
|
float
|
third row, second element |
required |
v22
|
float
|
third row, third element |
required |
v23
|
float
|
third row, fourth element |
required |
v30
|
float
|
fourth row, first element |
required |
v31
|
float
|
fourth row, second element |
required |
v32
|
float
|
fourth row, third element |
required |
v33
|
float
|
fourth row, fourth element |
required |
Translate(vec)
Translate the matrix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vec
|
Vector3D
|
Vector of translation. |
required |
Transpose()
Transpose matrix
All transform-services multiply transformation-matrix from the right side: If you need the result as it would be multiplication from the left side you need the transposed Matrix
[x,y,z,1.0] x / 0, 1, 2, 3\ / 0, 1, 2, 3\ / x | 4, 5, 6, 7 | | 4, 5, 6, 7 | x | y | | 8, 9,10,11 | | 8, 9,10,11 | | z | \ 12,13,14,15 / \ 12,13,14,15 / .0/
moving-part: 12,13,14 moving-part: 3, 7, 11
__add__(matrix)
Matrix addition
Formula: Result(new matrix) = A+B A is this matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix3D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix3D
|
Addition of matrices |
__eq__(mat)
Comparison of matrices without tolerance.
Be careful, this method work without tolerance!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arc
|
Compared arc. |
required |
Returns:
Type | Description |
---|---|
bool
|
True when matrices are equal, otherwise false. |
__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..15> |
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
|
Matrix3D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix3D
|
Addition of matrices |
__imul__(matrix)
Matrix multiplication
Formula: A = B or A = AB. A is this matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix3D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix3D
|
Product of matrices |
__init__
overload
__init__()
Initialize
__init__(proj)
Constructor
Create a matrix for the required projection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
proj
|
eProjectionMatrixType
|
The required projection |
required |
__init__(matrix)
Copy constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix3D
|
Matrix which will be copied. |
required |
__init__(v00, v01, v02, v03, v10, v11, v12, v13, v20, v21, v22, v23, v30, v31, v32, v33)
Constructor setting each matrix-element
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v00
|
float
|
first row, first element |
required |
v01
|
float
|
first row, second element |
required |
v02
|
float
|
first row, third element |
required |
v03
|
float
|
first row, fourth element |
required |
v10
|
float
|
second row, first element |
required |
v11
|
float
|
second row, second element |
required |
v12
|
float
|
second row, third element |
required |
v13
|
float
|
second row, fourth element |
required |
v20
|
float
|
third row, first element |
required |
v21
|
float
|
third row, second element |
required |
v22
|
float
|
third row, third element |
required |
v23
|
float
|
third row, fourth element |
required |
v30
|
float
|
fourth row, first element |
required |
v31
|
float
|
fourth row, second element |
required |
v32
|
float
|
fourth row, third element |
required |
v33
|
float
|
fourth row, fourth element |
required |
__init__(valuesinrows)
Constructor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
valuesinrows
|
list
|
matrix values by rows as Python list |
required |
__isub__(matrix)
Matrix addition
Formula: A -= B or A = A-B A is this matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix3D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix3D
|
Addition of matrices |
__mul__(matrix)
Matrix multiplication
Formula: Result(new matrix) = A*B A is this matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Matrix3D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix3D
|
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
|
Matrix3D
|
B matrix |
required |
Returns:
Type | Description |
---|---|
Matrix3D
|
Addition of matrices |