CVB++ 15.1
Loading...
Searching...
No Matches
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 {
60 }
61 };
62
63 class AffineMatrix3D;
64
66
74 inline AffineMatrix3D operator+(const AffineMatrix3D &lhs, const AffineMatrix3D &rhs) noexcept;
75
77
85 inline AffineMatrix3D operator-(const AffineMatrix3D &lhs, const AffineMatrix3D &rhs) noexcept;
86
88
96 inline AffineMatrix3D operator*(const AffineMatrix3D &lhs, const AffineMatrix3D &rhs);
97
99
107 inline AffineMatrix3D operator*(const AffineMatrix3D &lhs, const double &rhs) noexcept;
108
110
118 inline AffineMatrix3D operator*(const double &lhs, const AffineMatrix3D &rhs) noexcept;
119
121
129 inline AffineMatrix3D operator/(const AffineMatrix3D &lhs, const double &rhs);
130
132
135 class AffineMatrix3D final
136 {
137 public:
139
143 static AffineMatrix3D Identity() noexcept
144 {
146 }
147
149
152 AffineMatrix3D() noexcept = default;
153
155
160 AffineMatrix3D(Matrix3D matrix, Vector3D<double> translation) noexcept
161 : translation_(translation)
162 , matrix_(matrix)
163 {
164 }
165
167
171 Matrix3D Matrix() const noexcept
172 {
173 return matrix_;
174 }
175
177
181 void SetMatrix(Matrix3D matrix) noexcept
182 {
183 matrix_ = matrix;
184 }
185
187
192 {
193 return translation_;
194 }
195
197
201 void SetTranslation(Vector3D<double> translation) noexcept
202 {
203 translation_ = translation;
204 }
205
207
211 bool IsTranslation() const noexcept
212 {
213 return matrix_ == Cvb::Matrix3D::Identity();
214 }
215
217
221 double Det() const
222 {
223 return Internal::DoResCallValueOut<double>([&](double &value) {
224 auto thisData = reinterpret_cast<const CExports::CVC3DTransformation *>(this);
225 return CVB_CALL_CAPI(CVC3DTransformationDeterminant(*thisData, value));
226 });
227 }
228
230
235 void Invert()
236 {
237 Internal::DoResCall([&]() {
238 auto data = reinterpret_cast<const CExports::CVC3DTransformation *>(this);
239 auto dataInv = reinterpret_cast<CExports::CVC3DTransformation *>(this);
240 return CVB_CALL_CAPI(CVC3DInvertTransformation(*data, *dataInv));
241 });
242 }
243
245
252 {
253 auto result = *this;
254 result.Invert();
255 return result;
256 }
257
259
264 bool operator==(const AffineMatrix3D &transformation) const noexcept
265 {
266 return translation_ == transformation.translation_ && matrix_ == transformation.matrix_;
267 }
268
270
275 bool operator!=(const AffineMatrix3D &transformation) const noexcept
276 {
277 return !(*this == transformation);
278 }
279
281
286 AffineMatrix3D &operator+=(const AffineMatrix3D &transformation) noexcept
287 {
288 *this = *this + transformation;
289 return *this;
290 }
291
293
298 AffineMatrix3D &operator-=(const AffineMatrix3D &transformation) noexcept
299 {
300 *this = *this - transformation;
301 return *this;
302 }
303
305
311 {
312 *this = *this * transformation;
313 return *this;
314 }
315
317
322 AffineMatrix3D &operator*=(const double &value) noexcept
323 {
324 *this = *this * value;
325 return *this;
326 }
327
329
334 AffineMatrix3D &operator/=(const double &value) noexcept
335 {
336 *this = *this / value;
337 return *this;
338 }
339
340 private:
341 Vector3D<double> translation_;
342 Matrix3D matrix_;
343 };
344
345 inline AffineMatrix3D operator+(const AffineMatrix3D &lhs, const AffineMatrix3D &rhs) noexcept
346 {
347 return AffineMatrix3D(lhs.Matrix() + rhs.Matrix(), lhs.Translation() + rhs.Translation());
348 }
349
350 inline AffineMatrix3D operator-(const AffineMatrix3D &lhs, const AffineMatrix3D &rhs) noexcept
351 {
352 return AffineMatrix3D(lhs.Matrix() - rhs.Matrix(), lhs.Translation() - rhs.Translation());
353 }
354
356 {
357
358 return Internal::DoResCallValueOut<AffineMatrix3D>([&](AffineMatrix3D &value) {
359 auto valueData = reinterpret_cast<CExports::CVC3DTransformation *>(&value);
360 auto lhsData = reinterpret_cast<const CExports::CVC3DTransformation *>(&lhs);
361 auto rhsData = reinterpret_cast<const CExports::CVC3DTransformation *>(&rhs);
362 return CVB_CALL_CAPI(CVC3DMultiplyTransformations(*lhsData, *rhsData, *valueData));
363 });
364 }
365
366 inline AffineMatrix3D operator*(const AffineMatrix3D &lhs, const double &rhs) noexcept
367 {
368 return AffineMatrix3D(lhs.Matrix() * rhs, lhs.Translation() * rhs);
369 }
370
371 inline AffineMatrix3D operator*(const double &lhs, const AffineMatrix3D &rhs) noexcept
372 {
373 return rhs * lhs;
374 }
375
376 inline AffineMatrix3D operator/(const AffineMatrix3D &lhs, const double &rhs)
377 {
378 return AffineMatrix3D(lhs.Matrix() / rhs, lhs.Translation() / rhs);
379 }
380
381 CVB_END_INLINE_NS
382
383} // namespace Cvb
AffineMatrix3D Inverse()
Gets the inverse of this transformation if possible.
Definition affine_matrix_3d.hpp:251
bool operator==(const AffineMatrix3D &transformation) const noexcept
Compares to an other transformation.
Definition affine_matrix_3d.hpp:264
AffineMatrix3D & operator*=(const double &value) noexcept
Multiplies and assigns to this transformation.
Definition affine_matrix_3d.hpp:322
static AffineMatrix3D Identity() noexcept
The identity element.
Definition affine_matrix_3d.hpp:143
Vector3D< double > Translation() const noexcept
Gets the translation part of the transformation.
Definition affine_matrix_3d.hpp:191
Matrix3D Matrix() const noexcept
Gets the matrix part of the transformation.
Definition affine_matrix_3d.hpp:171
AffineMatrix3D & operator*=(const AffineMatrix3D &transformation)
Multiplies and assigns to this transformation.
Definition affine_matrix_3d.hpp:310
AffineMatrix3D & operator/=(const double &value) noexcept
Divides each element of this transformation by the given value.
Definition affine_matrix_3d.hpp:334
AffineMatrix3D() noexcept=default
Default constructor for empty transformation.
bool IsTranslation() const noexcept
Checks if this transformation describes a translation.
Definition affine_matrix_3d.hpp:211
double Det() const
Transformation determinant.
Definition affine_matrix_3d.hpp:221
bool operator!=(const AffineMatrix3D &transformation) const noexcept
Compares to an other transformation.
Definition affine_matrix_3d.hpp:275
void SetTranslation(Vector3D< double > translation) noexcept
Sets the translation part of the transformation.
Definition affine_matrix_3d.hpp:201
AffineMatrix3D & operator-=(const AffineMatrix3D &transformation) noexcept
Subtracts and assigns to this transformation.
Definition affine_matrix_3d.hpp:298
void SetMatrix(Matrix3D matrix) noexcept
Sets the matrix part of the transformation.
Definition affine_matrix_3d.hpp:181
void Invert()
Inverts this transformation in-place if possible.
Definition affine_matrix_3d.hpp:235
AffineMatrix3D & operator+=(const AffineMatrix3D &transformation) noexcept
Adds and assigns to this affine matrix.
Definition affine_matrix_3d.hpp:286
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 version.hpp:11
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