CVB++ 15.0
affine_matrix_3d.hpp
1#pragma once
2
3#include "_cexports/c_core_3d.h"
4
5#include "global.hpp"
6#include "matrix_3d.hpp"
7#include "point_3d.hpp"
8
9namespace Cvb
10{
11
12 CVB_BEGIN_INLINE_NS
13
15
36 {
39
42
44 double Syx = 0;
45
47 double Syz = 0;
48
50 double InclinationX = 0;
51
53 double InclinationZ = 0;
54
57 : RotationAngles(Vector3D<double>(0, 0, 0))
58 , Scale(Factors3D(1, 1, 1))
59 , Syx(0)
60 , Syz(0)
61 , InclinationX(0)
62 , InclinationZ(0)
63 {
64 }
65 };
66
67 class AffineMatrix3D;
68
70
78 inline AffineMatrix3D operator+(const AffineMatrix3D &lhs, const AffineMatrix3D &rhs) noexcept;
79
81
89 inline AffineMatrix3D operator-(const AffineMatrix3D &lhs, const AffineMatrix3D &rhs) noexcept;
90
92
100 inline AffineMatrix3D operator*(const AffineMatrix3D &lhs, const AffineMatrix3D &rhs);
101
103
111 inline AffineMatrix3D operator*(const AffineMatrix3D &lhs, const double &rhs) noexcept;
112
114
122 inline AffineMatrix3D operator*(const double &lhs, const AffineMatrix3D &rhs) noexcept;
123
125
133 inline AffineMatrix3D operator/(const AffineMatrix3D &lhs, const double &rhs);
134
136
139 class AffineMatrix3D final
140 {
141 public:
143
147 static AffineMatrix3D Identity() noexcept
148 {
150 }
151
153
156 AffineMatrix3D() noexcept = default;
157
159
164 AffineMatrix3D(Matrix3D matrix, Vector3D<double> translation) noexcept
165 : matrix_(matrix)
166 , translation_(translation)
167 {
168 }
169
171
175 Matrix3D Matrix() const noexcept
176 {
177 return matrix_;
178 }
179
181
185 void SetMatrix(Matrix3D matrix) noexcept
186 {
187 matrix_ = matrix;
188 }
189
191
196 {
197 return translation_;
198 }
199
201
205 void SetTranslation(Vector3D<double> translation) noexcept
206 {
207 translation_ = translation;
208 }
209
211
215 bool IsTranslation() const noexcept
216 {
217 return matrix_ == Cvb::Matrix3D::Identity();
218 }
219
221
225 double Det() const
226 {
227 return Internal::DoResCallValueOut<double>([&](double &value) {
228 auto thisData = reinterpret_cast<const CExports::CVC3DTransformation *>(this);
229 return CVB_CALL_CAPI(CVC3DTransformationDeterminant(*thisData, value));
230 });
231 }
232
234
239 void Invert()
240 {
241 Internal::DoResCall([&]() {
242 auto data = reinterpret_cast<const CExports::CVC3DTransformation *>(this);
243 auto dataInv = reinterpret_cast<CExports::CVC3DTransformation *>(this);
244 return CVB_CALL_CAPI(CVC3DInvertTransformation(*data, *dataInv));
245 });
246 }
247
249
256 {
257 auto result = *this;
258 result.Invert();
259 return result;
260 }
261
263
268 bool operator==(const AffineMatrix3D &transformation) const noexcept
269 {
270 return translation_ == transformation.translation_ && matrix_ == transformation.matrix_;
271 }
272
274
279 bool operator!=(const AffineMatrix3D &transformation) const noexcept
280 {
281 return !(*this == transformation);
282 }
283
285
290 AffineMatrix3D &operator+=(const AffineMatrix3D &transformation) noexcept
291 {
292 *this = *this + transformation;
293 return *this;
294 }
295
297
302 AffineMatrix3D &operator-=(const AffineMatrix3D &transformation) noexcept
303 {
304 *this = *this - transformation;
305 return *this;
306 }
307
309
315 {
316 *this = *this * transformation;
317 return *this;
318 }
319
321
326 AffineMatrix3D &operator*=(const double &value) noexcept
327 {
328 *this = *this * value;
329 return *this;
330 }
331
333
338 AffineMatrix3D &operator/=(const double &value) noexcept
339 {
340 *this = *this / value;
341 return *this;
342 }
343
344 private:
345 Vector3D<double> translation_;
346 Matrix3D matrix_;
347 };
348
349 inline AffineMatrix3D operator+(const AffineMatrix3D &lhs, const AffineMatrix3D &rhs) noexcept
350 {
351 return AffineMatrix3D(lhs.Matrix() + rhs.Matrix(), lhs.Translation() + rhs.Translation());
352 }
353
354 inline AffineMatrix3D operator-(const AffineMatrix3D &lhs, const AffineMatrix3D &rhs) noexcept
355 {
356 return AffineMatrix3D(lhs.Matrix() - rhs.Matrix(), lhs.Translation() - rhs.Translation());
357 }
358
360 {
361
362 return Internal::DoResCallValueOut<AffineMatrix3D>([&](AffineMatrix3D &value) {
363 auto valueData = reinterpret_cast<CExports::CVC3DTransformation *>(&value);
364 auto lhsData = reinterpret_cast<const CExports::CVC3DTransformation *>(&lhs);
365 auto rhsData = reinterpret_cast<const CExports::CVC3DTransformation *>(&rhs);
366 return CVB_CALL_CAPI(CVC3DMultiplyTransformations(*lhsData, *rhsData, *valueData));
367 });
368 }
369
370 inline AffineMatrix3D operator*(const AffineMatrix3D &lhs, const double &rhs) noexcept
371 {
372 return AffineMatrix3D(lhs.Matrix() * rhs, lhs.Translation() * rhs);
373 }
374
375 inline AffineMatrix3D operator*(const double &lhs, const AffineMatrix3D &rhs) noexcept
376 {
377 return rhs * lhs;
378 }
379
380 inline AffineMatrix3D operator/(const AffineMatrix3D &lhs, const double &rhs)
381 {
382 return AffineMatrix3D(lhs.Matrix() / rhs, lhs.Translation() / rhs);
383 }
384
385 CVB_END_INLINE_NS
386
387} // namespace Cvb
AffineMatrix3D Inverse()
Gets the inverse of this transformation if possible.
Definition affine_matrix_3d.hpp:255
bool operator==(const AffineMatrix3D &transformation) const noexcept
Compares to an other transformation.
Definition affine_matrix_3d.hpp:268
AffineMatrix3D & operator*=(const double &value) noexcept
Multiplies and assigns to this transformation.
Definition affine_matrix_3d.hpp:326
static AffineMatrix3D Identity() noexcept
The identity element.
Definition affine_matrix_3d.hpp:147
Vector3D< double > Translation() const noexcept
Gets the translation part of the transformation.
Definition affine_matrix_3d.hpp:195
Matrix3D Matrix() const noexcept
Gets the matrix part of the transformation.
Definition affine_matrix_3d.hpp:175
AffineMatrix3D & operator*=(const AffineMatrix3D &transformation)
Multiplies and assigns to this transformation.
Definition affine_matrix_3d.hpp:314
AffineMatrix3D & operator/=(const double &value) noexcept
Divides each element of this transformation by the given value.
Definition affine_matrix_3d.hpp:338
AffineMatrix3D() noexcept=default
Default constructor for empty transformation.
bool IsTranslation() const noexcept
Checks if this transformation describes a translation.
Definition affine_matrix_3d.hpp:215
double Det() const
Transformation determinant.
Definition affine_matrix_3d.hpp:225
bool operator!=(const AffineMatrix3D &transformation) const noexcept
Compares to an other transformation.
Definition affine_matrix_3d.hpp:279
void SetTranslation(Vector3D< double > translation) noexcept
Sets the translation part of the transformation.
Definition affine_matrix_3d.hpp:205
AffineMatrix3D & operator-=(const AffineMatrix3D &transformation) noexcept
Subtracts and assigns to this transformation.
Definition affine_matrix_3d.hpp:302
void SetMatrix(Matrix3D matrix) noexcept
Sets the matrix part of the transformation.
Definition affine_matrix_3d.hpp:185
void Invert()
Inverts this transformation in-place if possible.
Definition affine_matrix_3d.hpp:239
AffineMatrix3D & operator+=(const AffineMatrix3D &transformation) noexcept
Adds and assigns to this affine matrix.
Definition affine_matrix_3d.hpp:290
Double precision 3x3 matrix class.
Definition matrix_3d.hpp:54
static Matrix3D Identity() noexcept
The identity element.
Definition matrix_3d.hpp:61
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
AffineMatrix2D operator+(const AffineMatrix2D &lhs, const AffineMatrix2D &rhs) noexcept
Add two affine matrices.
Definition affine_matrix_2d.hpp:223
AffineMatrix2D operator*(const AffineMatrix2D &lhs, const AffineMatrix2D &rhs) noexcept
Multiply two affine matrices.
Definition affine_matrix_2d.hpp:251
Point3D< T > Vector3D
Alias for Point3D.
Definition point_3d.hpp:363
AffineMatrix2D operator/(const AffineMatrix2D &lhs, const double &rhs)
Divide affine matrix by scalar.
Definition affine_matrix_2d.hpp:307
AffineMatrix2D operator-(const AffineMatrix2D &lhs, const AffineMatrix2D &rhs) noexcept
Subtract two affine matrices.
Definition affine_matrix_2d.hpp:237
Vector3D< double > RotationAngles
Rotation angles about x, y and z in [degree].
Definition affine_matrix_3d.hpp:38
double InclinationZ
Inclination of laser plane (rotation about z axis) in [degree].
Definition affine_matrix_3d.hpp:53
double Syx
Shear Syx (induced by InclinationZ).
Definition affine_matrix_3d.hpp:44
double InclinationX
Inclination of laser plane (rotation about x axis) in [degree].
Definition affine_matrix_3d.hpp:50
Factors3D Scale
Scale factors.
Definition affine_matrix_3d.hpp:41
AffineTransformationParameters()
Creates a new AffineTransformationParameters object with default values.
Definition affine_matrix_3d.hpp:56
double Syz
Shear Syz (induced by InclinationX).
Definition affine_matrix_3d.hpp:47
Factor components to be applied in the 3D domain.
Definition core_3d.hpp:16