CVB++ 14.0
Matrix2D Class Referencefinal

Double precision 2x2 matrix class. More...

#include <cvb/matrix_2d.hpp>

Public Member Functions

 Matrix2D () noexcept=default
 Default constructor for empty matrix. More...
 
template<std::size_t N>
 Matrix2D (const double(&list)[N]) noexcept
 Construct a 2x2 matrix with an initializer list. More...
 
 Matrix2D (double a11, double a12, double a21, double a22) noexcept
 Construct a 2x2 matrix. More...
 
 Matrix2D (Angle rotation, double scale=1.0) noexcept
 Construct a 2x2 matrix that is a combination of a rotation and scale operation. More...
 
 Matrix2D (double scale) noexcept
 Construct a 2x2 matrix that represents a scaling. More...
 
 Matrix2D (double scaleX, double scaleY) noexcept
 Constructs a 2x2 matrix that represent a scaling with different scaling in x and y directions. More...
 
 Matrix2D (Cvb::Point2D< double > column1, Cvb::Point2D< double > column2) noexcept
 Construct a 2x2 matrix from two column vectors. More...
 
const double * operator[] (int row) const noexcept
 Index based element access. More...
 
double * operator[] (int row) noexcept
 Index based element access. More...
 
const double & At (int row, int column) const noexcept
 Index based element access. More...
 
double & At (int row, int column) noexcept
 Index based element access. More...
 
double A11 () const noexcept
 Gets top left matrix element. More...
 
void SetA11 (double a11) noexcept
 Sets top left matrix element. More...
 
double A12 () const noexcept
 Gets top right matrix element. More...
 
void SetA12 (double a12) noexcept
 Sets top right matrix element. More...
 
double A21 () const noexcept
 Gets bottom left matrix element. More...
 
void SetA21 (double a21) noexcept
 Sets bottom left matrix element. More...
 
double A22 () const noexcept
 Gets bottom right matrix element. More...
 
void SetA22 (double a22) noexcept
 Sets bottom right matrix element. More...
 
double Det () const noexcept
 Matrix determinant. More...
 
void Invert ()
 Inverts this matrix if possible. More...
 
bool operator== (const Matrix2D &matrix) const noexcept
 Compares to an other matrix. More...
 
bool operator!= (const Matrix2D &matrix) const noexcept
 Compares to an other matrix. More...
 
Matrix2Doperator+= (const Matrix2D &matrix) noexcept
 Adds and assigns to this matrix. More...
 
Matrix2Doperator-= (const Matrix2D &matrix) noexcept
 Subtracts and assigns to this matrix. More...
 
Matrix2Doperator*= (const Matrix2D &matrix) noexcept
 Multiplies and assigns to this matrix. More...
 
Matrix2Doperator*= (const double &value) noexcept
 Multiplies and assigns to this matrix. More...
 
Matrix2Doperator/= (const double &value) noexcept
 Divides each element of this matrix by the given value. More...
 

Static Public Member Functions

static Matrix2D Identity () noexcept
 The identity element. More...
 

Related Functions

(Note that these are not member functions.)

Matrix2D operator+ (const Matrix2D &lhs, const Matrix2D &rhs)
 Add two matrices. More...
 
Matrix2D operator- (const Matrix2D &lhs, const Matrix2D &rhs)
 Substract two matrices. More...
 
Matrix2D operator* (const Matrix2D &lhs, const Matrix2D &rhs)
 Multiply two matrices. More...
 
Point2D< double > operator* (const Matrix2D &lhs, const Point2D< double > &rhs)
 Multiply matrix with 2D point. More...
 
Matrix2D operator* (const Matrix2D &lhs, const double &rhs)
 Multiply matrix with scalar. More...
 
Matrix2D operator* (const double &lhs, const Matrix2D &rhs)
 Multiply scalar with matrix . More...
 
Matrix2D operator/ (const Matrix2D &lhs, const double &rhs)
 Divide matrix by scalar. More...
 

Detailed Description

Double precision 2x2 matrix class.

Constructor & Destructor Documentation

◆ Matrix2D() [1/7]

Matrix2D ( )
defaultnoexcept

Default constructor for empty matrix.

Exceptions
Doesnot throw any exception.

◆ Matrix2D() [2/7]

Matrix2D ( const double(&)  list[N])
inlinenoexcept

Construct a 2x2 matrix with an initializer list.

Parameters
[in]listContaining exactly 4 elements.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Matrix2D() [3/7]

Matrix2D ( double  a11,
double  a12,
double  a21,
double  a22 
)
inlinenoexcept

Construct a 2x2 matrix.

Parameters
[in]a11Top left matrix element.
[in]a12Top right matrix element.
[in]a21Bottom left matrix element.
[in]a22Bottom right matrix element.
Exceptions
Doesnot throw any exception.

◆ Matrix2D() [4/7]

Matrix2D ( Angle  rotation,
double  scale = 1.0 
)
inlinenoexcept

Construct a 2x2 matrix that is a combination of a rotation and scale operation.

Parameters
[in]rotationRotation angle to create the matrix for.
[in]scaleScale factor to create the matrix for.
Exceptions
Doesnot throw any exception.

◆ Matrix2D() [5/7]

Matrix2D ( double  scale)
inlinenoexcept

Construct a 2x2 matrix that represents a scaling.

Parameters
[in]scaleScale factor to create the matrix for.
Exceptions
Doesnot throw any exception.

◆ Matrix2D() [6/7]

Matrix2D ( double  scaleX,
double  scaleY 
)
inlinenoexcept

Constructs a 2x2 matrix that represent a scaling with different scaling in x and y directions.

Parameters
[in]scaleXScale factor in X direction to create the matrix.
[in]scaleYScale factor in Y direction to create the matrix.
Exceptions
Doesnot throw any exception.

◆ Matrix2D() [7/7]

Matrix2D ( Cvb::Point2D< double >  column1,
Cvb::Point2D< double >  column2 
)
inlinenoexcept

Construct a 2x2 matrix from two column vectors.

Parameters
[in]column1Column vector one.
[in]column2Columns vector two.
Exceptions
Doesnot throw any exception.

Member Function Documentation

◆ A11()

double A11 ( ) const
inlinenoexcept

Gets top left matrix element.

Returns
double The element.
Exceptions
Doesnot throw any exception.

◆ A12()

double A12 ( ) const
inlinenoexcept

Gets top right matrix element.

Returns
double The element.
Exceptions
Doesnot throw any exception.

◆ A21()

double A21 ( ) const
inlinenoexcept

Gets bottom left matrix element.

Returns
double The element.
Exceptions
Doesnot throw any exception.

◆ A22()

double A22 ( ) const
inlinenoexcept

Gets bottom right matrix element.

Returns
double The element.
Exceptions
Doesnot throw any exception.

◆ At() [1/2]

const double & At ( int  row,
int  column 
) const
inlinenoexcept

Index based element access.

Parameters
[in]rowThe row to access.
[in]columnThe column to access.
Returns
The matrix element.
Exceptions
Doesnot throw any exception.

◆ At() [2/2]

double & At ( int  row,
int  column 
)
inlinenoexcept

Index based element access.

Parameters
[in]rowThe row to access.
[in]columnThe column to access.
Returns
The matrix element.
Exceptions
Doesnot throw any exception.

◆ Det()

double Det ( ) const
inlinenoexcept

Matrix determinant.

Returns
The determinant.
Exceptions
Doesnot throw any exception.

◆ Identity()

static Matrix2D Identity ( )
inlinestaticnoexcept

The identity element.

Returns
An identity matrix.
Exceptions
Doesnot throw any exception.

◆ Invert()

void Invert ( )
inline

Inverts this matrix if possible.

Exceptions
Anyexception derived from std::exception including CvbException.

Might cause division by zero.

◆ operator!=()

bool operator!= ( const Matrix2D matrix) const
inlinenoexcept

Compares to an other matrix.

Parameters
[in]matrixOther matrix.
Returns
True if not equal, otherwise false.
Exceptions
Doesnot throw any exception.

◆ operator*=() [1/2]

Matrix2D & operator*= ( const double &  value)
inlinenoexcept

Multiplies and assigns to this matrix.

Parameters
[in]valueFactor.
Returns
This matrix.
Exceptions
Doesnot throw any exception.

◆ operator*=() [2/2]

Matrix2D & operator*= ( const Matrix2D matrix)
inlinenoexcept

Multiplies and assigns to this matrix.

Parameters
[in]matrixOther matrix.
Returns
This matrix.
Exceptions
Doesnot throw any exception.

◆ operator+=()

Matrix2D & operator+= ( const Matrix2D matrix)
inlinenoexcept

Adds and assigns to this matrix.

Parameters
[in]matrixOther matrix.
Returns
This matrix.
Exceptions
Doesnot throw any exception.

◆ operator-=()

Matrix2D & operator-= ( const Matrix2D matrix)
inlinenoexcept

Subtracts and assigns to this matrix.

Parameters
[in]matrixOther matrix.
Returns
This matrix.
Exceptions
Doesnot throw any exception.

◆ operator/=()

Matrix2D & operator/= ( const double &  value)
inlinenoexcept

Divides each element of this matrix by the given value.

Parameters
[in]valueDivisor.
Returns
This matrix.
Exceptions
Doesnot throw any exception.

◆ operator==()

bool operator== ( const Matrix2D matrix) const
inlinenoexcept

Compares to an other matrix.

Parameters
[in]matrixOther matrix.
Returns
True if equal, otherwise false.
Exceptions
Doesnot throw any exception.

◆ operator[]() [1/2]

const double * operator[] ( int  row) const
inlinenoexcept

Index based element access.

Parameters
[in]row
Returns
A raw pointer to the row
Exceptions
Doesnot throw any exception.

◆ operator[]() [2/2]

double * operator[] ( int  row)
inlinenoexcept

Index based element access.

Parameters
[in]row
Returns
A raw pointer to the row
Exceptions
Doesnot throw any exception.

◆ SetA11()

void SetA11 ( double  a11)
inlinenoexcept

Sets top left matrix element.

Parameters
[in]a11The element.
Exceptions
Doesnot throw any exception.

◆ SetA12()

void SetA12 ( double  a12)
inlinenoexcept

Sets top right matrix element.

Parameters
[in]a12The element.
Exceptions
Doesnot throw any exception.

◆ SetA21()

void SetA21 ( double  a21)
inlinenoexcept

Sets bottom left matrix element.

Parameters
[in]a21The element.
Exceptions
Doesnot throw any exception.

◆ SetA22()

void SetA22 ( double  a22)
inlinenoexcept

Sets bottom right matrix element.

Parameters
[in]a22The element.
Exceptions
Doesnot throw any exception.

Friends And Related Function Documentation

◆ operator*() [1/4]

Matrix2D operator* ( const double &  lhs,
const Matrix2D rhs 
)
related

Multiply scalar with matrix .

Parameters
[in]lhsRight hand side value.
[in]rhsLeft hand side matrix.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ operator*() [2/4]

Matrix2D operator* ( const Matrix2D lhs,
const double &  rhs 
)
related

Multiply matrix with scalar.

Parameters
[in]lhsRight hand side matrix.
[in]rhsLeft hand side value.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ operator*() [3/4]

Matrix2D operator* ( const Matrix2D lhs,
const Matrix2D rhs 
)
related

Multiply two matrices.

Parameters
[in]lhsRight hand side matrix.
[in]rhsLeft hand side matrix.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ operator*() [4/4]

Point2D< double > operator* ( const Matrix2D lhs,
const Point2D< double > &  rhs 
)
related

Multiply matrix with 2D point.

Parameters
[in]lhsRight hand side matrix.
[in]rhsLeft hand side point.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ operator+()

Matrix2D operator+ ( const Matrix2D lhs,
const Matrix2D rhs 
)
related

Add two matrices.

Parameters
[in]lhsRight hand side matrix.
[in]rhsLeft hand side matrix.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ operator-()

Matrix2D operator- ( const Matrix2D lhs,
const Matrix2D rhs 
)
related

Substract two matrices.

Parameters
[in]lhsRight hand side matrix.
[in]rhsLeft hand side matrix.
Returns
The computation result.
Exceptions
Doesnot throw any exception.

◆ operator/()

Matrix2D operator/ ( const Matrix2D lhs,
const double &  rhs 
)
related

Divide matrix by scalar.

Parameters
[in]lhsRight hand side matrix.
[in]rhsLeft hand side value.
Returns
The computation result.
Exceptions
Doesnot throw any exception.