C3D Toolkit  Kernel - 110050, Vision - 2.5.0.18

The extended matrix of transformation in a two-dimensional space. More...

#include <mb_matrix.h>

+ Collaboration diagram for MbMatrix:

Public Member Functions

 MbMatrix ()
 Default constructor.
 
 MbMatrix (const MbMatrix &init)
 Copy constructor.
 
 MbMatrix (const MbPlacement &place)
 The constructor by placement.
 
 MbMatrix (const MbCartPoint &pnt, const MbDirection &dir)
 The constructor by a point and a normalized vector. More...
 
 MbMatrix (const MbCartPoint &pc, double sx, double sy)
 The constructor of scaling matrix by x and y. More...
 
 MbMatrix (const MbCartPoint &pc, double angle)
 The constructor of rotation matrix. More...
 
 ~MbMatrix ()
 Destructor.
 
void GetProperties (MbProperties &properties)
 Get properties of the object.
 
void SetProperties (const MbProperties &properties)
 Set properties of the object.
 
Initialization functions.
MbMatrixInit ()
 Initialize a matrix as unit one.
 
MbMatrixInit (const MbCartPoint &pnt, const MbDirection &dir)
 Initialize a matrix by a point and normalized vector. More...
 
MbMatrixInit (const MbCartPoint &pc, double sx, double sy)
 Initialize scaling matrix by x and y. More...
 
MbMatrixInit (const MbCartPoint &pc, double angle)
 Initialize a rotation matrix. More...
 
MbMatrixSet (const MbPlacement &place)
 Initialize a matrix according to a placement. More...
 
MbMatrixSetZero ()
 Set a zero matrix.
 
Functions for check of matrices properties.
bool IsInvert () const
 Get an attribute of negativity of the determinant of a rotation matrix.
 
bool IsInvertEps (double eps=EXTENT_EPSILON) const
 Get an attribute of negativity of the determinant of a rotation matrix.
 
bool IsSingle () const
 Get an attribute of unit matrix.
 
bool IsSingleEps (double eps=LENGTH_EPSILON) const
 Get an attribute of the identity matrix with a given tolerance.
 
bool IsTranslation () const
 Get an attribute of inequality to zero of translation vector.
 
bool IsRotation () const
 Get an attribute of non-identity of a rotation matrix.
 
bool IsLeft () const
 Get an attribute of the left-definite matrix.
 
bool IsOrt () const
 Get an attribute of orthogonality for the case if the matrix is affine.
 
bool IsOrthogonal () const
 Get an attribute of orthogonality for the case if the matrix is a rotation matrix.
 
bool IsAffine () const
 Get an attribute that the rotational matrix is arbitrary and affine.
 
bool IsScaling () const
 Get an attribute of inequality to 1.0 of a scale component. More...
 
bool IsPerspective () const
 
bool IsUnSet () const
 Check whether bit flags are not set.
 
bool IsSame (const MbMatrix &, double accuracy) const
 Determine whether an object is equal?
 
bool IsTranslationOnly () const
 Get an attribute that there is only translation.
 
bool IsSubstitutionOnly (double epsilon=METRIC_EPSILON) const
 Are the axis described by the matrix local system coincide with global axes up to a 90-degree rotation?
 
bool IsIsotropic (double &l) const
 Get an attribute of isotropism. More...
 
bool CanTransformGabarit () const
 Is it possible to transform a bounding box without distortion?
 
Functions of access to matrix elements.
double El (size_t i, size_t j) const
 Get an element of the matrix.
 
const double * GetEl () const
 Get a pointer to the first matrix element.
 
const MbVectorGetAxisX () const
 Get the first row (the X-axis).
 
const MbVectorGetAxisY () const
 Get the second row (the Y-axis).
 
const MbCartPointGetOrigin () const
 Get the third row (the origin of coordinates)
 
MbVector GetColumn (size_t i) const
 Get the i-th column vector of the matrix.
 
MbVector GetRow (size_t i) const
 Get the i-th row-vector of the matrix.
 
MbHomogeneous GetFullColumn (size_t i) const
 Get the i-th column vector of the matrix.
 
MbHomogeneous GetFullRow (size_t i) const
 Get the i-th row-vector of the matrix.
 
Functions for matrix elements modification.
void El (size_t i, size_t j, double e)
 Assign a value to the matrix element. More...
 
void AddEl (size_t i, size_t j, double e)
 Add a number to the matrix element. More...
 
void MulEl (size_t i, size_t j, double e)
 Multiply the matrix element by a number. More...
 
void SetColumn (size_t icol, const MbCartPoint &column)
 Assign point coordinates values to column elements. More...
 
void SetColumn (size_t icol, const MbVector &column)
 Assign vector components values to column elements. More...
 
void SetColumn (size_t icol, const MbHomogeneous &column)
 Assign coordinates of the uniform point to column elements. More...
 
void SetRow (size_t irow, const MbVector &row)
 Assign vector components values to row elements. More...
 
void SetRow (size_t irow, const MbCartPoint &row)
 Assign point coordinates values to row elements. More...
 
void SetRow (size_t irow, const MbHomogeneous &row)
 Assign coordinates of the uniform point to row elements. More...
 
void SetOrigin (const MbCartPoint &p)
 Set components of matrix translation.
 
Matrices multiplication.
MbMatrixPreMultiply (const MbMatrix &)
 Multiply a matrix on the left.
 
MbMatrixPostMultiply (const MbMatrix &)
 Multiply a matrix on the right.
 
Scaling functions.
MbMatrixScale (double s)
 Scale by X and Y.
 
void ScaleX (double s)
 Scale by X.
 
void ScaleY (double s)
 Scale by Y.
 
double GetScaleX () const
 Get scaling coefficient by X.
 
double GetScaleY () const
 Get scaling coefficient by Y.
 
bool IsDifferentScale () const
 Check differences of scaling coefficients (X and Y).
 
Functions of matrix transformations: translation, rotation, etc.
void Shift (double shift)
 Shift by X and Y.
 
void ShiftX (double shift)
 Shift by X.
 
void ShiftY (double shift)
 Shift by Y.
 
MbMatrixMove (const MbVector &v)
 Translate by the vector (multiply by translation matrix on the right).
 
MbMatrixMove (double dx, double dy)
 Translate by given increments.
 
MbMatrixRotate (double angle)
 Rotate by an angle. More...
 
MbMatrixRotate (const MbDirection &)
 Rotate according to the direction vector. More...
 
MbMatrixRotate (const MbCartPoint &, const MbDirection &angle)
 Rotate at angle around a point. More...
 
void TransformCoord (double x, double y, double &xn, double &yn) const
 Transform coordinates. More...
 
void TransformScalarX (double &len) const
 Transform the length in the direction of 0X. More...
 
MbMatrixSymmetry (const MbCartPoint &origin, const MbVector &normal)
 Set the matrix to symmetry transformation (reflection). More...
 
MbMatrixSymmetry (const MbCartPoint &origin, const MbDirection &direction)
 Find a matrix for transformation of symmetry relative to a line given by a point and direction.
 
Calculation of the algebraic properties of a matrix.
void Adj ()
 Transpose a matrix.
 
double Delta (size_t line, size_t column, size_t dim) const
 Calculate the algebraic adjunct.
 
double Det (size_t dim) const
 Calculate the determinant of a matrix.
 
void Div (MbMatrix &) const
 Calculate inverse matrix.
 
double NormMax () const
 Maximal element of the matrix in absolute value.
 
Overload of arithmetical and logical operations.
MbMatrix operator* (const MbMatrix &) const
 Multiply by the matrix on the right.
 
MbMatrixoperator*= (const MbMatrix &m)
 Multiply by the matrix on the right.
 
MbMatrixoperator= (const MbMatrix &m)
 Assign a value.
 
bool operator== (const MbMatrix &) const
 Compare with a matrix(tolerance- LENGTH_EPSILON).
 
double & operator() (size_t i, size_t j)
 Access to a matrix element by a reference.
 
const double & operator() (size_t i, size_t j) const
 The value of a matrix element.
 

Static Public Attributes

static const MbMatrix identity
 Identity matrix, I = diag(1,1,1);.
 

Protected Attributes

double el [MATRIX_DIM_2D][MATRIX_DIM_2D]
 Elements of matrix.
 

Friends

void MulMatrix (const MbMatrix &, const MbMatrix &, MbMatrix &)
 Multiply matrices. More...
 

Detailed Description

The extended matrix of transformation in a two-dimensional space.

The extended matrix of transformation in a two-dimensional space.
The extended matrix has dimension (3, 3) and is a regular matrix bordered below by a translation vector and by the null column to the right. The transformation of point "p" by the matrix "M" has the form: r = p * M (the row of coordinates is multiplied by the matrix to the left).
The transformation matrix from a local coordinate system can be obtained as follows:
the first row must be filled with the corresponding components of the first vector of a local system, the second row must be filled with the corresponding components of the second vector of a local system, the last row of the matrix must be filled with the corresponding coordinates of a local system origin. The matrix of transformation consists of four blocks:
| R, P | | V, S | where R - is a rotation matrix, the tensor with dimension (2, 2), V - translation vector, tensor (0, 2), P - perspective vector, the tensor (2, 0) (always null), S - scalar of scale transformation (the unit). \ n

Constructor & Destructor Documentation

◆ MbMatrix() [1/3]

MbMatrix::MbMatrix ( const MbCartPoint pnt,
const MbDirection dir 
)
inline

The constructor by a point and a normalized vector.

The constructor by a point and a normalized vector

Parameters
[in]pnt- A point. Sets translation relative to zero.
[in]dir- Unit vector. Sets a rotation.

◆ MbMatrix() [2/3]

MbMatrix::MbMatrix ( const MbCartPoint pc,
double  sx,
double  sy 
)
inline

The constructor of scaling matrix by x and y.

The constructor of scaling matrix by x and y.

Parameters
[in]pnt- A point. Sets translation relative to zero.
[in]sx,sy- Scaling coefficients by x and y, respectively.

◆ MbMatrix() [3/3]

MbMatrix::MbMatrix ( const MbCartPoint pc,
double  angle 
)
inline

The constructor of rotation matrix.

The constructor of rotation matrix around the point "pc" on the angle "angle".

Parameters
[in]pc- A point.
[in]angle- A rotation angle.

Member Function Documentation

◆ Init() [1/3]

MbMatrix & MbMatrix::Init ( const MbCartPoint pnt,
const MbDirection dir 
)
inline

Initialize a matrix by a point and normalized vector.

Initialize a matrix by a point and normalized vector.

Parameters
[in]pnt- A point. Sets translation relative to zero.
[in]dir- Unit vector. Sets a rotation.

◆ Init() [2/3]

MbMatrix& MbMatrix::Init ( const MbCartPoint pc,
double  sx,
double  sy 
)

Initialize scaling matrix by x and y.

Initialize scaling matrix by x and y.

Parameters
[in]pnt- A point. Sets translation relative to zero.
[in]sx,sy- Scaling coefficients by the x and y, respectively.

◆ Init() [3/3]

MbMatrix& MbMatrix::Init ( const MbCartPoint pc,
double  angle 
)

Initialize a rotation matrix.

Initialize a rotation matrix around the point "pc" on the angle "angle".

Parameters
[in]pc- A point.
[in]angle- A rotation angle.

◆ Set()

MbMatrix& MbMatrix::Set ( const MbPlacement place)

Initialize a matrix according to a placement.

Initialize a matrix according to a placement.

Parameters
[in]place- The initial placement.

◆ IsScaling()

bool MbMatrix::IsScaling ( ) const
inline

Get an attribute of inequality to 1.0 of a scale component.

Get an attribute of inequality to zero of perspective vector.

◆ IsIsotropic()

bool MbMatrix::IsIsotropic ( double &  l) const

Get an attribute of isotropism.

Checks whether the matrix is orthogonal with equal lengths of
X and Y axes (circle remains a circle).

Parameters
[out]l- The length of the X and Y axes orts.
Returns
Returns true if the matrix is isotropic.

◆ El()

void MbMatrix::El ( size_t  i,
size_t  j,
double  e 
)
inline

Assign a value to the matrix element.

Assign a value to the matrix element.

Parameters
[in]i- A row index.
[in]j- A column index.
[in]e- Initial value which to be assigned to an element of the matrix.

◆ AddEl()

void MbMatrix::AddEl ( size_t  i,
size_t  j,
double  e 
)
inline

Add a number to the matrix element.

Add a number to the matrix element.

Parameters
[in]i- A row index.
[in]j- A column index.
[in]e- Initial number which to be added to the matrix element.

◆ MulEl()

void MbMatrix::MulEl ( size_t  i,
size_t  j,
double  e 
)
inline

Multiply the matrix element by a number.

Multiply the matrix element by a number.

Parameters
[in]i- A row index.
[in]j- A column index.
[in]e- Initial number by which to multiply the matrix element.

◆ SetColumn() [1/3]

void MbMatrix::SetColumn ( size_t  icol,
const MbCartPoint column 
)

Assign point coordinates values to column elements.

Assign point coordinates values to column elements.

Parameters
[in]icol- A column index.
[in]column- The initial point.

◆ SetColumn() [2/3]

void MbMatrix::SetColumn ( size_t  icol,
const MbVector column 
)

Assign vector components values to column elements.

Assign vector components values to column elements.

Parameters
[in]icol- A column index.
[in]column- The initial vector.

◆ SetColumn() [3/3]

void MbMatrix::SetColumn ( size_t  icol,
const MbHomogeneous column 
)

Assign coordinates of the uniform point to column elements.

Assign coordinates of the uniform point to column elements.

Parameters
[in]icol- A column index.
[in]column- The initial point.

◆ SetRow() [1/3]

void MbMatrix::SetRow ( size_t  irow,
const MbVector row 
)

Assign vector components values to row elements.

Assign vector components values to row elements.

Parameters
[in]irow- A column index.
[in]row- The initial vector.

◆ SetRow() [2/3]

void MbMatrix::SetRow ( size_t  irow,
const MbCartPoint row 
)

Assign point coordinates values to row elements.

Assign point coordinates values to row elements.

Parameters
[in]irow- A column index.
[in]row- The initial point.

◆ SetRow() [3/3]

void MbMatrix::SetRow ( size_t  irow,
const MbHomogeneous row 
)

Assign coordinates of the uniform point to row elements.

Assign coordinates of the uniform point to row elements.

Parameters
[in]irow- A column index.
[in]row- The initial point.

◆ Rotate() [1/3]

MbMatrix& MbMatrix::Rotate ( double  angle)

Rotate by an angle.

Rotation is around the axis Z.

Parameters
[in]angle- A rotation angle.

◆ Rotate() [2/3]

MbMatrix& MbMatrix::Rotate ( const MbDirection )

Rotate according to the direction vector.

Rotation is around the Z axis, because matrix is two-dimensional. A direction vector defines a rotation angle.

Parameters
[in]-A direction vector.

◆ Rotate() [3/3]

MbMatrix& MbMatrix::Rotate ( const MbCartPoint ,
const MbDirection angle 
)

Rotate at angle around a point.

Rotate at angle around a point.

Parameters
[in]-A point.
[in]angle- A direction vector which defines a rotation angle

◆ TransformCoord()

void MbMatrix::TransformCoord ( double  x,
double  y,
double &  xn,
double &  yn 
) const
inline

Transform coordinates.

Coordinates are transformed according to a matrix.

Parameters
[in]x,y- Old coordinates by x and y.
[in]xn,yn- Transformed coordinates.

◆ TransformScalarX()

void MbMatrix::TransformScalarX ( double &  len) const
inline

Transform the length in the direction of 0X.

The length is transformed according to a matrix. If the matrix has a different scales for the X and Y, then the scale by Y is ignored.

Parameters
[in,out]len- The length in the direction of 0X.

◆ Symmetry()

MbMatrix& MbMatrix::Symmetry ( const MbCartPoint origin,
const MbVector normal 
)

Set the matrix to symmetry transformation (reflection).

The matrix of symmetry transformation is found relative to a line which is defined by a point and the normal.

Parameters
[in]origin- A point of a line.
[in]normal- The normal of a line.

Friends And Related Function Documentation

◆ MulMatrix

void MulMatrix ( const MbMatrix ,
const MbMatrix ,
MbMatrix  
)
friend

Multiply matrices.

Multiply m1 matrix by m2 matrix (instead of res = m1 * m2).

Parameters
[in]m1,m2- Initial matrices.
[out]res- The required matrix.

The documentation for this class was generated from the following file: