40 template<std::
size_t N>
43 static_assert(N == 4,
"CVB: Matrix2D must have 4 elements");
44 std::copy(std::begin(list), std::end(list), &a11_);
55 Matrix2D(
double a11,
double a12,
double a21,
double a22) noexcept
71 a11_ = (scale *
Cos(rotation));
73 a21_ = scale *
Sin(rotation);
94 Matrix2D(
double scaleX,
double scaleY) noexcept
106 :
Matrix2D(column1.X(), column2.X(), column1.Y(), column2.Y())
120 return &((&a11_)[row << 1]);
131 return &((&a11_)[row << 1]);
142 const double&
At(
int row,
int column)
const noexcept
144 return (*
this)[row][column];
154 double&
At(
int row,
int column)
noexcept
156 return (*
this)[row][column];
165 double A11() const noexcept
185 double A12() const noexcept
205 double A21() const noexcept
225 double A22() const noexcept
245 double Det() const noexcept
247 return a11_ * a22_ - a21_ * a12_;
259 double det_1 = 1.0 /
Det();
260 *
this =
Matrix2D(a22_ * det_1, -a12_ * det_1, -a21_ * det_1, a11_ * det_1);
271 return a11_ == matrix.a11_
272 && a12_ == matrix.a12_
273 && a21_ == matrix.a21_
274 && a22_ == matrix.a22_;
285 return !(*
this == matrix);
326 *
this =
Matrix2D(a11_ * matrix.a11_ + a12_ * matrix.a21_,
327 a11_ * matrix.a12_ + a12_ * matrix.a22_,
328 a21_ * matrix.a11_ + a22_ * matrix.a21_,
329 a21_ * matrix.a12_ + a22_ * matrix.a22_);
Object for convenient and type - safe handling of angles.
Definition: angle.hpp:19
Double precision 2x2 matrix class.
Definition: matrix_2d.hpp:16
const double & At(int row, int column) const noexcept
Index based element access.
Definition: matrix_2d.hpp:142
Matrix2D(Cvb::Point2D< double > column1, Cvb::Point2D< double > column2) noexcept
Construct a 2x2 matrix from two column vectors.
Definition: matrix_2d.hpp:105
Matrix2D operator+(const Matrix2D &lhs, const Matrix2D &rhs)
Add two matrices.
Definition: matrix_2d.hpp:384
Matrix2D operator*(const double &lhs, const Matrix2D &rhs)
Multiply scalar with matrix .
Definition: matrix_2d.hpp:457
Matrix2D operator*(const Matrix2D &lhs, const Matrix2D &rhs)
Multiply two matrices.
Definition: matrix_2d.hpp:412
bool operator!=(const Matrix2D &matrix) const noexcept
Compares to an other matrix.
Definition: matrix_2d.hpp:283
void SetA12(double a12) noexcept
Sets top right matrix element.
Definition: matrix_2d.hpp:195
const double * operator[](int row) const noexcept
Index based element access.
Definition: matrix_2d.hpp:117
double A11() const noexcept
Gets top left matrix element.
Definition: matrix_2d.hpp:165
double * operator[](int row) noexcept
Index based element access.
Definition: matrix_2d.hpp:129
Point2D< double > operator*(const Matrix2D &lhs, const Point2D< double > &rhs)
Multiply matrix with 2D point.
Definition: matrix_2d.hpp:429
void SetA11(double a11) noexcept
Sets top left matrix element.
Definition: matrix_2d.hpp:175
static Matrix2D Identity() noexcept
The identity element.
Definition: matrix_2d.hpp:24
double A22() const noexcept
Gets bottom right matrix element.
Definition: matrix_2d.hpp:225
Matrix2D operator/(const Matrix2D &lhs, const double &rhs)
Divide matrix by scalar.
Definition: matrix_2d.hpp:471
Matrix2D operator-(const Matrix2D &lhs, const Matrix2D &rhs)
Substract two matrices.
Definition: matrix_2d.hpp:398
double A12() const noexcept
Gets top right matrix element.
Definition: matrix_2d.hpp:185
Matrix2D & operator-=(const Matrix2D &matrix) noexcept
Subtracts and assigns to this matrix.
Definition: matrix_2d.hpp:309
double A21() const noexcept
Gets bottom left matrix element.
Definition: matrix_2d.hpp:205
Matrix2D operator*(const Matrix2D &lhs, const double &rhs)
Multiply matrix with scalar.
Definition: matrix_2d.hpp:443
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:69
bool operator==(const Matrix2D &matrix) const noexcept
Compares to an other matrix.
Definition: matrix_2d.hpp:269
double Det() const noexcept
Matrix determinant.
Definition: matrix_2d.hpp:245
Matrix2D & operator+=(const Matrix2D &matrix) noexcept
Adds and assigns to this matrix.
Definition: matrix_2d.hpp:294
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:94
Matrix2D & operator*=(const Matrix2D &matrix) noexcept
Multiplies and assigns to this matrix.
Definition: matrix_2d.hpp:324
void Invert()
Inverts this matrix if possible.
Definition: matrix_2d.hpp:257
Matrix2D & operator/=(const double &value) noexcept
Divides each element of this matrix by the given value.
Definition: matrix_2d.hpp:354
Matrix2D() noexcept=default
Default constructor for empty matrix.
double & At(int row, int column) noexcept
Index based element access.
Definition: matrix_2d.hpp:154
void SetA22(double a22) noexcept
Sets bottom right matrix element.
Definition: matrix_2d.hpp:235
Matrix2D(double a11, double a12, double a21, double a22) noexcept
Construct a 2x2 matrix.
Definition: matrix_2d.hpp:55
Matrix2D(double scale) noexcept
Construct a 2x2 matrix that represents a scaling.
Definition: matrix_2d.hpp:83
void SetA21(double a21) noexcept
Sets bottom left matrix element.
Definition: matrix_2d.hpp:215
T X() const noexcept
Gets the x-component of the point.
Definition: point_2d.hpp:86
T Y() const noexcept
Gets the y-component of the point.
Definition: point_2d.hpp:106
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
double Sin(Angle angle) noexcept
Returns the sine of an angle.
Definition: angle.hpp:438
double Cos(Angle angle) noexcept
Returns the cosine of an angle.
Definition: angle.hpp:411