39 template <std::
size_t N>
42 static_assert(N == 4,
"CVB: Matrix2D must have 4 elements");
54 Matrix2D(
double a11,
double a12,
double a21,
double a22) noexcept
54 Matrix2D(
double a11,
double a12,
double a21,
double a22) noexcept {
…}
70 a11_ = (scale *
Cos(rotation));
72 a21_ = scale *
Sin(rotation);
92 Matrix2D(
double scaleX,
double scaleY) noexcept
104 :
Matrix2D(column1.X(), column2.X(), column1.Y(), column2.Y())
117 return &((&a11_)[row << 1]);
128 return &((&a11_)[row << 1]);
138 const double &
At(
int row,
int column)
const noexcept
140 return (*
this)[row][column];
138 const double &
At(
int row,
int column)
const noexcept {
…}
150 double &
At(
int row,
int column)
noexcept
152 return (*
this)[row][column];
150 double &
At(
int row,
int column)
noexcept {
…}
160 double A11() const noexcept
160 double A11() const noexcept {
…}
180 double A12() const noexcept
180 double A12() const noexcept {
…}
200 double A21() const noexcept
200 double A21() const noexcept {
…}
220 double A22() const noexcept
220 double A22() const noexcept {
…}
240 double Det() const noexcept
242 return a11_ * a22_ - a21_ * a12_;
240 double Det() const noexcept {
…}
268 double det_1 = 1.0 /
Det();
269 return Matrix2D(a22_ * det_1, -a12_ * det_1, -a21_ * det_1, a11_ * det_1);
280 return a11_ == matrix.a11_ && a12_ == matrix.a12_ && a21_ == matrix.a21_ && a22_ == matrix.a22_;
291 return !(*
this == matrix);
332 *
this =
Matrix2D(a11_ * matrix.a11_ + a12_ * matrix.a21_, a11_ * matrix.a12_ + a12_ * matrix.a22_,
333 a21_ * matrix.a11_ + a22_ * matrix.a21_, a21_ * matrix.a12_ + a22_ * matrix.a22_);
Object for convenient and type - safe handling of angles.
Definition angle.hpp:16
const double & At(int row, int column) const noexcept
Index based element access.
Definition matrix_2d.hpp:138
Matrix2D(Cvb::Point2D< double > column1, Cvb::Point2D< double > column2) noexcept
Construct a 2x2 matrix from two column vectors.
Definition matrix_2d.hpp:103
Matrix2D operator+(const Matrix2D &lhs, const Matrix2D &rhs)
Add two matrices.
Definition matrix_2d.hpp:383
Matrix2D operator*(const double &lhs, const Matrix2D &rhs)
Multiply scalar with matrix .
Definition matrix_2d.hpp:454
Matrix2D operator*(const Matrix2D &lhs, const Matrix2D &rhs)
Multiply two matrices.
Definition matrix_2d.hpp:411
bool operator!=(const Matrix2D &matrix) const noexcept
Compares to an other matrix.
Definition matrix_2d.hpp:289
void SetA12(double a12) noexcept
Sets top right matrix element.
Definition matrix_2d.hpp:190
const double * operator[](int row) const noexcept
Index based element access.
Definition matrix_2d.hpp:114
double A11() const noexcept
Gets top left matrix element.
Definition matrix_2d.hpp:160
double * operator[](int row) noexcept
Index based element access.
Definition matrix_2d.hpp:126
Point2D< double > operator*(const Matrix2D &lhs, const Point2D< double > &rhs)
Multiply matrix with 2D point.
Definition matrix_2d.hpp:426
void SetA11(double a11) noexcept
Sets top left matrix element.
Definition matrix_2d.hpp:170
static Matrix2D Identity() noexcept
The identity element.
Definition matrix_2d.hpp:23
double A22() const noexcept
Gets bottom right matrix element.
Definition matrix_2d.hpp:220
Matrix2D operator/(const Matrix2D &lhs, const double &rhs)
Divide matrix by scalar.
Definition matrix_2d.hpp:468
Matrix2D & operator*=(const double &value) noexcept
Multiplies and assigns to this matrix.
Definition matrix_2d.hpp:343
Matrix2D operator-(const Matrix2D &lhs, const Matrix2D &rhs)
Substract two matrices.
Definition matrix_2d.hpp:397
double A12() const noexcept
Gets top right matrix element.
Definition matrix_2d.hpp:180
Matrix2D & operator-=(const Matrix2D &matrix) noexcept
Subtracts and assigns to this matrix.
Definition matrix_2d.hpp:315
double A21() const noexcept
Gets bottom left matrix element.
Definition matrix_2d.hpp:200
Matrix2D operator*(const Matrix2D &lhs, const double &rhs)
Multiply matrix with scalar.
Definition matrix_2d.hpp:440
Matrix2D(Angle rotation, double scale=1.0) noexcept
Construct a 2x2 matrix that is a combination of a rotation and scale operation.
Definition matrix_2d.hpp:68
bool operator==(const Matrix2D &matrix) const noexcept
Compares to an other matrix.
Definition matrix_2d.hpp:278
double Det() const noexcept
Matrix determinant.
Definition matrix_2d.hpp:240
Matrix2D & operator+=(const Matrix2D &matrix) noexcept
Adds and assigns to this matrix.
Definition matrix_2d.hpp:300
Matrix2D(double scaleX, double scaleY) noexcept
Constructs a 2x2 matrix that represent a scaling with different scaling in x and y directions.
Definition matrix_2d.hpp:92
Matrix2D & operator*=(const Matrix2D &matrix) noexcept
Multiplies and assigns to this matrix.
Definition matrix_2d.hpp:330
void Invert()
Inverts this matrix in-place if possible.
Definition matrix_2d.hpp:251
Matrix2D & operator/=(const double &value) noexcept
Divides each element of this matrix by the given value.
Definition matrix_2d.hpp:358
Matrix2D() noexcept=default
Default constructor for empty matrix.
double & At(int row, int column) noexcept
Index based element access.
Definition matrix_2d.hpp:150
void SetA22(double a22) noexcept
Sets bottom right matrix element.
Definition matrix_2d.hpp:230
Matrix2D(double a11, double a12, double a21, double a22) noexcept
Construct a 2x2 matrix.
Definition matrix_2d.hpp:54
Matrix2D(double scale) noexcept
Construct a 2x2 matrix that represents a scaling.
Definition matrix_2d.hpp:81
Matrix2D Inverse()
Gets the inverse of this matrix if possible.
Definition matrix_2d.hpp:263
void SetA21(double a21) noexcept
Sets bottom left matrix element.
Definition matrix_2d.hpp:210
Multi-purpose 2D vector class.
Definition point_2d.hpp:20
T X() const noexcept
Gets the x-component of the point.
Definition point_2d.hpp:84
T Y() const noexcept
Gets the y-component of the point.
Definition point_2d.hpp:104
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
double Sin(Angle angle) noexcept
Returns the sine of an angle.
Definition angle.hpp:429
double Cos(Angle angle) noexcept
Returns the cosine of an angle.
Definition angle.hpp:403