5#include "_cexports/c_core_3d.h"
10#include "point_3d.hpp"
31inline Matrix3D
operator+(
const Matrix3D & lhs,
const Matrix3D & rhs);
42inline Matrix3D
operator-(
const Matrix3D & lhs,
const Matrix3D & rhs);
54inline Matrix3D
operator*(
const Matrix3D & lhs,
const Matrix3D & rhs);
88 template<std::
size_t N>
91 static_assert(N == 9,
"CVB: Matrix3D must have 9 elements");
92 std::copy(std::begin(list), std::end(list), matrix_.data()->data());
111 Internal::DoResCall([&]()
113 auto thisData =
reinterpret_cast<CExports::CVC3DMatrix*
>(
this);
114 return CVB_CALL_CAPI(CVC3DRotationMatrixFromRotationAngles(alpha, beta, gamma, *thisData));
136 Internal::DoResCall([&]()
138 auto thisData =
reinterpret_cast<CExports::CVC3DMatrix*
>(
this);
139 return CVB_CALL_CAPI(CVC3DMatrixFromRotationAnglesScale(alpha, beta, gamma, *
reinterpret_cast<CExports::CVC3DFactors*
>(&scale), *thisData));
165 auto thisData =
reinterpret_cast<const CExports::CVC3DMatrix*
>(
this);
212 Internal::DoResCall([&]()
215 auto thisData =
reinterpret_cast<const CExports::CVC3DMatrix*
>(
this);
216 auto errcode = CVB_CALL_CAPI(CVC3DRotationAnglesScaleFromMatrix(*thisData, alpha, beta, gamma, *
reinterpret_cast<CExports::CVC3DFactors*
>(&scale)));
220 return CVB_CALL_CAPI(CVC3DRotationAnglesScaleFromMatrixApproximation(*thisData, alpha, beta, gamma, *
reinterpret_cast<CExports::CVC3DFactors*
>(&scale), precision));
245 Internal::DoResCall([&]()
247 auto thisData =
reinterpret_cast<const CExports::CVC3DMatrix*
>(
this);
248 return CVB_CALL_CAPI(CVC3DRollPitchYawFromRotationMatrix(*thisData, roll, pitch, yaw));
261 return matrix_[row].data();
273 return matrix_[row].data();
283 const double&
At(
int row,
int column)
const noexcept
285 return (*
this)[row][column];
295 double&
At(
int row,
int column)
noexcept
297 return (*
this)[row][column];
307 return Internal::DoResCallValueOut<double>([&](
double & value)
309 auto thisData =
reinterpret_cast<const CExports::CVC3DMatrix*
>(
this);
310 return CVB_CALL_CAPI(CVC3DMatrixDeterminant(*thisData, value));
323 Internal::DoResCall([&]()
325 auto data =
reinterpret_cast<const CExports::CVC3DMatrix*
>(
this);
326 auto dataInv =
reinterpret_cast<CExports::CVC3DMatrix*
>(
this);
327 return CVB_CALL_CAPI(CVC3DInvertMatrix(*data, *dataInv));
353 return matrix_ == matrix.matrix_;
364 return !(*
this == matrix);
375 *
this = *
this + matrix;
387 *
this = *
this - matrix;
399 *
this = *
this * matrix;
411 for (
auto & line : matrix_)
412 for (
auto & element : line)
425 for(
auto & line : matrix_)
426 for(
auto & element : line)
446 lhs[0][0] + rhs[0][0], lhs[0][1] + rhs[0][1], lhs[0][2] + rhs[0][2],
447 lhs[1][0] + rhs[1][0], lhs[1][1] + rhs[1][1], lhs[1][2] + rhs[1][2],
448 lhs[2][0] + rhs[2][0], lhs[2][1] + rhs[2][1], lhs[2][2] + rhs[2][2],
457 lhs[0][0] - rhs[0][0], lhs[0][1] - rhs[0][1], lhs[0][2] - rhs[0][2],
458 lhs[1][0] - rhs[1][0], lhs[1][1] - rhs[1][1], lhs[1][2] - rhs[1][2],
459 lhs[2][0] - rhs[2][0], lhs[2][1] - rhs[2][1], lhs[2][2] - rhs[2][2],
467 return Internal::DoResCallValueOut<Matrix3D>([&](
Matrix3D & value)
469 auto valueData =
reinterpret_cast<CExports::CVC3DMatrix*
>(&value);
470 auto lhsData =
reinterpret_cast<const CExports::CVC3DMatrix*
>(&lhs);
471 auto rhsData =
reinterpret_cast<const CExports::CVC3DMatrix*
>(&rhs);
472 return CVB_CALL_CAPI(CVC3DMultiplyMatrices(*lhsData,
492 lhs[0][0] * rhs[0] + lhs[0][1] * rhs[1] + lhs[0][2] * rhs[2],
493 lhs[1][0] * rhs[0] + lhs[1][1] * rhs[1] + lhs[1][2] * rhs[2],
494 lhs[2][0] * rhs[0] + lhs[2][1] * rhs[1] + lhs[2][2] * rhs[2],
511 lhs[0][0] * rhs, lhs[0][1] * rhs, lhs[0][2] * rhs,
512 lhs[1][0] * rhs, lhs[1][1] * rhs, lhs[1][2] * rhs,
513 lhs[2][0] * rhs, lhs[2][1] * rhs, lhs[2][2] * rhs
544 lhs[0][0] / rhs, lhs[0][1] / rhs, lhs[0][2] / rhs,
545 lhs[1][0] / rhs, lhs[1][1] / rhs, lhs[1][2] / rhs,
546 lhs[2][0] / rhs, lhs[2][1] / rhs, lhs[2][2] / rhs
Double precision 3x3 matrix class.
Definition: matrix_3d.hpp:60
const double & At(int row, int column) const noexcept
Index based element access.
Definition: matrix_3d.hpp:283
Matrix3D(double alpha, double beta, double gamma, Factors3D scale)
Creates a transformation matrix from the given Euler angles and scaling.
Definition: matrix_3d.hpp:134
bool operator!=(const Matrix3D &matrix) const noexcept
Compares to an other matrix.
Definition: matrix_3d.hpp:362
void RotationAnglesScale(double &alpha, double &beta, double &gamma, Factors3D &scale, double &precision) const
Computes the Euler angles and scaling from the matrix.
Definition: matrix_3d.hpp:210
Matrix3D & operator*=(const Matrix3D &matrix)
Multiplies and assigns to this matrix.
Definition: matrix_3d.hpp:397
const double * operator[](int row) const noexcept
Index based element access.
Definition: matrix_3d.hpp:259
Matrix3D Inverse()
Gets the inverse of this matrix if possible.
Definition: matrix_3d.hpp:338
bool operator==(const Matrix3D &matrix) const noexcept
Compares to an other matrix.
Definition: matrix_3d.hpp:351
bool TryGetRotationAngles(double &alpha, double &beta, double &gamma) const noexcept
Tries to compute the Euler angles from the matrix.
Definition: matrix_3d.hpp:163
double * operator[](int row) noexcept
Index based element access.
Definition: matrix_3d.hpp:271
void RollPitchYaw(double &roll, double &pitch, double &yaw) const
Computes the Euler angles Roll, Pitch and Yaw for this matrix.
Definition: matrix_3d.hpp:243
Matrix3D operator*(const double &lhs, const Matrix3D &rhs)
Multiply scalar with matrix .
Definition: matrix_3d.hpp:526
Matrix3D() noexcept=default
Default constructor for empty matrix.
Matrix3D & operator/=(const double &value) noexcept
Divides each element of this matrix by the given value.
Definition: matrix_3d.hpp:423
double Det() const
Matrix determinant.
Definition: matrix_3d.hpp:305
Matrix3D & operator-=(const Matrix3D &matrix) noexcept
Subtracts and assigns to this matrix.
Definition: matrix_3d.hpp:385
Matrix3D(double alpha, double beta, double gamma)
Creates a rotation matrix from the given Euler angles.
Definition: matrix_3d.hpp:109
Matrix3D operator/(const Matrix3D &lhs, const double &rhs)
Divide matrix by scalar.
Definition: matrix_3d.hpp:540
Point3D< double > operator*(const Matrix3D &lhs, const Point3D< double > &rhs)
Multiply matrix with 3D point.
Definition: matrix_3d.hpp:488
void Invert()
Inverts this matrix in-place if possible.
Definition: matrix_3d.hpp:321
Matrix3D & operator+=(const Matrix3D &matrix) noexcept
Adds and assigns to this matrix.
Definition: matrix_3d.hpp:373
static Matrix3D Identity() noexcept
The identity element.
Definition: matrix_3d.hpp:68
double & At(int row, int column) noexcept
Index based element access.
Definition: matrix_3d.hpp:295
Matrix3D operator*(const Matrix3D &lhs, const double &rhs)
Multiply matrix with scalar.
Definition: matrix_3d.hpp:507
@ CVC_E_OK
No Error occurred.
Definition: CVCError.h:58
Root namespace for the Image Manager interface.
Definition: c_barcode.h:15
AffineMatrix2D operator+(const AffineMatrix2D &lhs, const AffineMatrix2D &rhs) noexcept
Add two affine matrices.
Definition: affine_matrix_2d.hpp:231
AffineMatrix2D operator*(const AffineMatrix2D &lhs, const AffineMatrix2D &rhs) noexcept
Multiply two affine matrices.
Definition: affine_matrix_2d.hpp:259
AffineMatrix2D operator-(const AffineMatrix2D &lhs, const AffineMatrix2D &rhs) noexcept
Subtract two affine matrices.
Definition: affine_matrix_2d.hpp:245
Factor components to be applied in the 3D domain.
Definition: core_3d.hpp:17