Double precision 3x3 matrix class. More...
Inherits object.
Public Member Functions | |
float | at (self, int row, int column) |
Index based element access. More... | |
cvb.Matrix3D | create () |
Creates a 3x3 matrix without any parameters. More... | |
cvb.Matrix3D | create (float alpha, float beta, float gamma) |
Creates a rotation matrix from the given Euler angles. More... | |
cvb.Matrix3D | create (float alpha, float beta, float gamma, cvb.Factors3D scale) |
Creates a transformation matrix from the given Euler angles and scaling. More... | |
cvb.Matrix3D | create (List[float] values) |
Creates a 3x3 matrix passing all matrix elements. More... | |
cvb.Matrix3D | identity () |
The identity element. More... | |
None | inverse (self) |
Gets the inverse of this matrix if possible. More... | |
None | invert (self) |
Inverts this matrix in-place if possible. More... | |
Properties | |
det = property | |
float: Matrix determinant. | |
precision = property | |
float: Precision of approximation. More... | |
roll_pitch_yaw = property | |
Tuple[float, float, float]: Roll, pitch and yaw values in degrees. More... | |
rotation_angles = property | |
Tuple[float, float, float]: Rotation angles alpha, beta and gamma in degrees. More... | |
scale = property | |
cvb.Factors3D: Scaling factors in x, y and z. More... | |
Double precision 3x3 matrix class.
An object of this class can be constructed using rotation angles and scale. Then the matrix will be computed via (scale is optional):
where
alpha, beta, gamma are the rotation angles around x, y, z,
sx, sy, sz are the scaling factors for x, y, z.
Returning the properties Matrix3D.rotation_angles and Matrix3D.scale of this class, they are always calculated from the matrix. As you can create a Matrix3D also by passing the values of the matrix elements, the matrix is not necessarily a valid rotation matrix. In this case an approximation is calculated. Then the rotation angles and scaling factors are estimated using the Nelder-Mead algorithm. Therefore a cost function is set up and minimized over several iterations. The minimum value after the iteration stopped is stored to Matrix3D.precision. If the given matrix is valid and not noisy, the Matrix3D.precision will be very low. Note, that this estimation does not work for large scaling factors or if all scaling factors are negative. In this case the output Matrix3D.precision will be large (in general greater 1). Then please norm your matrix first by dividing all matrix elements by a matrix norm (e.g. the Frobenius norm or other).
If the matrix only contains rotation and scaling, i.e. it is not noisy, then rotation angles and scaling factors are calculated directly (without approximation). Then Matrix3D.precision is equal -1. Note, that angles and scale are computed from the normed matrix and threfore positive as a start. If the determinant of the normed matrix is -1, the scaling factor in z is set to a negative value.
Supports the same arguments as cvb.Matrix3D.create.
*args : Any Parameters like cvb.Matrix3D.create.
**kwargs : Any Parameters like cvb.Matrix3D.create.
float at | ( | self, | |
int | row, | ||
int | column | ||
) |
Index based element access.
row : int The row to access.
column : int The column to access.
float The matrix element.
cvb.Matrix3D create | ( | ) |
cvb.Matrix3D create | ( | float | alpha, |
float | beta, | ||
float | gamma | ||
) |
Creates a rotation matrix from the given Euler angles.
The rotation matrix R is computed via:
where
alpha, beta, gamma are the rotation angles around x, y, z.
alpha : float Angle around x in degrees.
beta : float Angle around y axis in degrees.
gamma : float Angle around z axis in degrees.
cvb.Matrix3D A 3D 3x3 matrix.
cvb.Matrix3D create | ( | float | alpha, |
float | beta, | ||
float | gamma, | ||
cvb.Factors3D | scale | ||
) |
Creates a transformation matrix from the given Euler angles and scaling.
Note, that the scaling is applied before rotation:
where
alpha, beta, gamma are the rotation angles around x, y, z,
sx, sy, sz are the scaling factors for x, y, z.
alpha : float Angle around x in degrees.
beta : float Angle around y axis in degrees.
gamma : float Angle around z axis in degrees.
scale : cvb.Factors3D Scaling factors for x, y and z.
cvb.Matrix3D A 3D 3x3 matrix.
cvb.Matrix3D create | ( | List[float] | values | ) |
Creates a 3x3 matrix passing all matrix elements.
values : List[float] Containing exactly 9 elements.
cvb.Matrix3D A 3D 3x3 matrix.
cvb.Matrix3D identity | ( | ) |
None inverse | ( | self | ) |
Gets the inverse of this matrix if possible.
Might cause division by zero.
None invert | ( | self | ) |
Inverts this matrix in-place if possible.
Might cause division by zero.
|
static |
float: Precision of approximation.
If rotation angles and scale are calculated directly without approximation, this value is -1, otherwise it is greater/equal zero. For details see also description of Matrix3D.
|
static |
Tuple[float, float, float]: Roll, pitch and yaw values in degrees.
For roll, pitch, yaw, the rotation matrix is defined after the z-y'-x''convention (see https://en.wikipedia.org/wiki/Euler_angles). The rotation matrix is interpreted as:
R = Rz * Ry * Rx
where Rx, Ry, Rz is the rotation around x'', y', z.
|
static |
Tuple[float, float, float]: Rotation angles alpha, beta and gamma in degrees.
The matrix is interpreted as:
where
alpha, beta, gamma are the rotation angles around x, y, z.
For details see also description of Matrix3D.
|
static |
cvb.Factors3D: Scaling factors in x, y and z.
The matrix is interpreted as:
where
alpha, beta, gamma are the rotation angles around x, y, z.
sx, sy, sz are the scaling factors for x, y, z.
For details see also description of Matrix3D.