Skip to content

Matrix3D

Canonical 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.

Methods:

Determinant

Determinant() -> float

Calculate determinant

Returns:

  • float

    Determinant.

GaussInvert

GaussInvert() -> bool

Inverse matrix by Gauss

Returns:

  • bool

    True when operation is successful, otherwise false.

GetScaleX

GetScaleX() -> float

Get scale X

Returns:

  • float

    scale X

GetScaleY

GetScaleY() -> float

Get scale Y

Returns:

  • float

    scale Y

GetScaleZ

GetScaleZ() -> float

Get scale Z

Returns:

  • float

    scale Z

GetScaling

GetScaling() -> tuple[float, float, float]

Calculates the scaling factors from the matrix

Returns:

  • tuple[float, float, float]

    tuple(Scale in X axis, Scale in Y axis, Scale in Z axis)

GetTranslationVector

GetTranslationVector() -> Vector3D

Get translation part of a matrix

Returns:

  • Vector3D

    The vector of translation

GetVectorX

GetVectorX() -> Vector3D

Get vector X

Returns:

GetVectorY

GetVectorY() -> Vector3D

Get vector Y

Returns:

GetVectorZ

GetVectorZ() -> Vector3D

Get vector Z

Returns:

IsIdentity

IsIdentity() -> bool

Check to identity matrix

Returns:

  • bool

    Return true when is matrix identity, otherwise false.

LaplaceTransform

LaplaceTransform()

Transformation matrix by Laplace

Multiply

Multiply(matrix: Matrix3D) -> Matrix3D

Matrix multiplication

Formula: A = B or A = AB A is this matrix.

Parameters:

Returns:

ReduceZDimension

ReduceZDimension() -> Matrix2D

Create a 2D matrix from this 3D matrix

Returns:

  • Matrix2D

    a 2D matrix from this 3D matrix

Reflection

Reflection(plane: Plane3D)

Reflection across a plane

Parameters:

  • plane (Plane3D) –

    Reflection plane

Reverse

Reverse() -> bool

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:

  • bool

    True when operation is successful, otherwise false.

Rotation

Rotation(line: Line3D, angle: Angle) -> bool

Rotate the matrix

Rotate current matrix, not created new one.

Parameters:

  • line (Line3D) –

    Axis of rotation.

  • angle (Angle) –

    Angle of rotation.

Returns:

  • bool

    True when successful, otherwise false.

Scaling

Scaling(scaleX: float, scaleY: float, scaleZ: float)

Scale the matrix

Scale current matrix, not created new one.

Parameters:

  • scaleX (float) –

    Scale in X axis.

  • scaleY (float) –

    Scale in Y axis.

  • scaleZ (float) –

    Scale in Z axis.

SetIdentity

SetIdentity()

Initialize identity matrix

SetProjection

SetProjection(proj: eProjectionMatrixType)

Create a matrix for the required projection

Method throw THROW_GEO_EXCEPTION_INCORRECT_PARAMETERS_ geometry exception in case of invalid proj.

Parameters:

SetReflection

SetReflection(plane: Plane3D)

Initialize matrix only with reflection

Parameters:

  • plane (Plane3D) –

    Reflection plane

SetRotation overloaded

SetRotation(axis: Line3D, angle: Angle) -> bool

Initialize matrix only with rotation

Parameters:

  • axis (Line3D) –

    Axis of rotation.

  • angle (Angle) –

    Angle of rotation.

Returns:

  • bool

    True when successful, otherwise false.

SetRotation(startDirection: Vector3D, endDirection: Vector3D) -> bool

Initialize matrix only with rotation defined by start and end direction vectors

Parameters:

  • startDirection (Vector3D) –

    direction vector for start of rotation.

  • endDirection (Vector3D) –

    direction vector for end of rotation.

Returns:

  • bool

    True when successful, otherwise false.

SetScaling

SetScaling(scaleX: float, scaleY: float, scaleZ: float)

Initialize matrix only with scaling factors

Parameters:

  • scaleX (float) –

    Scale in X axis.

  • scaleY (float) –

    Scale in Y axis.

  • scaleZ (float) –

    Scale in Z axis.

SetTranslation

SetTranslation(vec: Vector3D)

Initialize matrix only with translation

Parameters:

  • vec (Vector3D) –

    Vector of translation.

SetValue

SetValue(index: int, value: float) -> bool

Set the matrix element at a specified position

Use this method when you don't want to catch exception by operator[].

Parameters:

  • index (int) –

    Position index <0..15>

  • value (float) –

    Value for set

Returns:

  • bool

    True when operation successful (index is not out of range), otherwise false.

SetValues

SetValues(
    v00: float,
    v01: float,
    v02: float,
    v03: float,
    v10: float,
    v11: float,
    v12: float,
    v13: float,
    v20: float,
    v21: float,
    v22: float,
    v23: float,
    v30: float,
    v31: float,
    v32: float,
    v33: float,
)

Sets each matrix-element

Parameters:

  • v00 (float) –

    first row, first element

  • v01 (float) –

    first row, second element

  • v02 (float) –

    first row, third element

  • v03 (float) –

    first row, fourth element

  • v10 (float) –

    second row, first element

  • v11 (float) –

    second row, second element

  • v12 (float) –

    second row, third element

  • v13 (float) –

    second row, fourth element

  • v20 (float) –

    third row, first element

  • v21 (float) –

    third row, second element

  • v22 (float) –

    third row, third element

  • v23 (float) –

    third row, fourth element

  • v30 (float) –

    fourth row, first element

  • v31 (float) –

    fourth row, second element

  • v32 (float) –

    fourth row, third element

  • v33 (float) –

    fourth row, fourth element

Translate

Translate(vec: Vector3D)

Translate the matrix

Parameters:

  • vec (Vector3D) –

    Vector of translation.

Transpose

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__

__add__(matrix: Matrix3D) -> Matrix3D

Matrix addition

Formula: Result(new matrix) = A+B A is this matrix.

Parameters:

Returns:

__eq__

__eq__(mat: Matrix3D) -> bool

Comparison of matrices without tolerance.

Be careful, this method work without tolerance!

Parameters:

  • arc

    Compared arc.

Returns:

  • bool

    True when matrices are equal, otherwise false.

__getitem__

__getitem__(index: int) -> float

Get the matrix element at a specified position

This method is checked and throwing Geometry::Exception when index is out of range.

Parameters:

  • index (int) –

    Position index <0..15>

Returns:

  • float

    Returns an element at a specified position.

__iadd__

__iadd__(matrix: Matrix3D) -> Matrix3D

Matrix addition

Formula: A += B or A = A+B A is this matrix.

Parameters:

Returns:

__imul__

__imul__(matrix: Matrix3D) -> Matrix3D

Matrix multiplication

Formula: A = B or A = AB. A is this matrix.

Parameters:

Returns:

__init__ overloaded

__init__()

Initialize

__init__(proj: eProjectionMatrixType)

Constructor

Create a matrix for the required projection.

Parameters:

__init__(matrix: Matrix3D)

Copy constructor

Parameters:

  • matrix (Matrix3D) –

    Matrix which will be copied.

__init__(
    v00: float,
    v01: float,
    v02: float,
    v03: float,
    v10: float,
    v11: float,
    v12: float,
    v13: float,
    v20: float,
    v21: float,
    v22: float,
    v23: float,
    v30: float,
    v31: float,
    v32: float,
    v33: float,
)

Constructor setting each matrix-element

Parameters:

  • v00 (float) –

    first row, first element

  • v01 (float) –

    first row, second element

  • v02 (float) –

    first row, third element

  • v03 (float) –

    first row, fourth element

  • v10 (float) –

    second row, first element

  • v11 (float) –

    second row, second element

  • v12 (float) –

    second row, third element

  • v13 (float) –

    second row, fourth element

  • v20 (float) –

    third row, first element

  • v21 (float) –

    third row, second element

  • v22 (float) –

    third row, third element

  • v23 (float) –

    third row, fourth element

  • v30 (float) –

    fourth row, first element

  • v31 (float) –

    fourth row, second element

  • v32 (float) –

    fourth row, third element

  • v33 (float) –

    fourth row, fourth element

__init__(valuesinrows: list)

Constructor

Parameters:

  • valuesinrows (list) –

    matrix values by rows as Python list

__isub__

__isub__(matrix: Matrix3D) -> Matrix3D

Matrix addition

Formula: A -= B or A = A-B A is this matrix.

Parameters:

Returns:

__mul__

__mul__(matrix: Matrix3D) -> Matrix3D

Matrix multiplication

Formula: Result(new matrix) = A*B A is this matrix.

Parameters:

Returns:

__repr__

__repr__() -> str

Convert to string

__sub__

__sub__(matrix: Matrix3D) -> Matrix3D

Matrix addition

Formula: Result(new matrix) = A-B A is this matrix.

Parameters:

Returns: