6 #include "point_2d.hpp" 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_);
Matrix2D & operator *=(const double &value) noexcept
Multiplies and assigns to this matrix.
Definition: matrix_2d.hpp:339
void SetA12(double a12) noexcept
Sets top right matrix element.
Definition: matrix_2d.hpp:195
double * operator[](int row) noexcept
Index based element access.
Definition: matrix_2d.hpp:129
double Cos(Angle angle) noexcept
Returns the cosine of an angle.
Definition: angle.hpp:411
Matrix2D & operator -=(const Matrix2D &matrix) noexcept
Subtracts and assigns to this matrix.
Definition: matrix_2d.hpp:309
void SetA11(double a11) noexcept
Sets top left matrix element.
Definition: matrix_2d.hpp:175
double A21() const noexcept
Gets bottom left matrix element.
Definition: matrix_2d.hpp:205
const double * operator[](int row) const noexcept
Index based element access.
Definition: matrix_2d.hpp:117
AffineMatrix2D operator+(const AffineMatrix2D &lhs, const AffineMatrix2D &rhs) noexcept
Add two affine matrices.
Definition: affine_matrix_2d.hpp:217
Matrix2D(double a11, double a12, double a21, double a22) noexcept
Construct a 2x2 matrix.
Definition: matrix_2d.hpp:55
static Matrix2D Identity() noexcept
The identity element.
Definition: matrix_2d.hpp:24
AffineMatrix2D operator/(const AffineMatrix2D &lhs, const double &rhs)
Divide affine matrix by scalar.
Definition: affine_matrix_2d.hpp:301
double Sin(Angle angle) noexcept
Returns the sine of an angle.
Definition: angle.hpp:438
Double precision 2x2 matrix class.
Definition: matrix_2d.hpp:15
Matrix2D(Cvb::Point2D< double > column1, Cvb::Point2D< double > column2) noexcept
Construct a 2x2 matrix from two column vectors.
Definition: matrix_2d.hpp:105
bool operator!=(const Matrix2D &matrix) const noexcept
Compares to an other matrix.
Definition: matrix_2d.hpp:283
double & At(int row, int column) noexcept
Index based element access.
Definition: matrix_2d.hpp:154
double Det() const noexcept
Matrix determinant.
Definition: matrix_2d.hpp:245
Root namespace for the Image Manager interface.
Definition: version.hpp:11
const double & At(int row, int column) const noexcept
Index based element access.
Definition: matrix_2d.hpp:142
bool operator==(const Matrix2D &matrix) const noexcept
Compares to an other matrix.
Definition: matrix_2d.hpp:269
T Y() const noexcept
Gets the y-component of the point.
Definition: point_2d.hpp:106
void SetA21(double a21) noexcept
Sets bottom left matrix element.
Definition: matrix_2d.hpp:215
Matrix2D & operator/=(const double &value) noexcept
Divides each element of this matrix by the given value.
Definition: matrix_2d.hpp:354
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
AffineMatrix2D operator *(const AffineMatrix2D &lhs, const AffineMatrix2D &rhs) noexcept
Multiply two affine matrices.
Definition: affine_matrix_2d.hpp:245
Matrix2D & operator+=(const Matrix2D &matrix) noexcept
Adds and assigns to this matrix.
Definition: matrix_2d.hpp:294
void SetA22(double a22) noexcept
Sets bottom right matrix element.
Definition: matrix_2d.hpp:235
T X() const noexcept
Gets the x-component of the point.
Definition: point_2d.hpp:86
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
void Invert()
Inverts this matrix if possible.
Definition: matrix_2d.hpp:257
double A22() const noexcept
Gets bottom right matrix element.
Definition: matrix_2d.hpp:225
Matrix2D() noexcept=default
Default constructor for empty matrix.
Matrix2D & operator *=(const Matrix2D &matrix) noexcept
Multiplies and assigns to this matrix.
Definition: matrix_2d.hpp:324
double A11() const noexcept
Gets top left matrix element.
Definition: matrix_2d.hpp:165
Matrix2D(double scale) noexcept
Construct a 2x2 matrix that represents a scaling.
Definition: matrix_2d.hpp:83
double A12() const noexcept
Gets top right matrix element.
Definition: matrix_2d.hpp:185
AffineMatrix2D operator-(const AffineMatrix2D &lhs, const AffineMatrix2D &rhs) noexcept
Subtract two affine matrices.
Definition: affine_matrix_2d.hpp:231
Object for convenient and type - safe handling of angles.
Definition: angle.hpp:18