MeshLib C++ Docs
Loading...
Searching...
No Matches
MRPointToPointAligningTransform.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRAffineXf3.h"
5
6namespace MR
7{
8
12
15class PointToPointAligningTransform
16{
17public:
19 MRMESH_API void add( const Vector3d& p1, const Vector3d& p2, double w = 1 );
20
22 void add( const Vector3f& p1, const Vector3f& p2, float w = 1 ) { add( Vector3d( p1 ), Vector3d( p2 ), w ); }
23
25 MRMESH_API void add( const PointToPointAligningTransform & other );
26
28 void clear() { *this = {}; }
29
31 [[nodiscard]] Vector3d centroid1() const { return sum1_ / sumW_; }
32
34 [[nodiscard]] Vector3d centroid2() const { return sum2_ / sumW_; }
35
37 [[nodiscard]] double totalWeight() const { return sumW_; }
38
42 [[nodiscard]] MRMESH_API AffineXf3d findBestRigidXf() const;
43
45 [[nodiscard]] MRMESH_API AffineXf3d findBestRigidScaleXf() const;
46
48 [[nodiscard]] MRMESH_API AffineXf3d findBestRigidXfFixedRotationAxis( const Vector3d& axis ) const;
49
51 [[nodiscard]] MRMESH_API AffineXf3d findBestRigidXfOrthogonalRotationAxis( const Vector3d& ort ) const;
52
54 [[nodiscard]] MRMESH_API Vector3d findBestTranslation() const;
55
56private:
57 struct BestRotation
58 {
59 Matrix3d rot;
60 double err = 0; // larger value means more discrepancy between points after registration
61 };
63 BestRotation findPureRotation_() const;
64
65private:
66 Matrix3d sum12_ = Matrix3d::zero();
67 Vector3d sum1_, sum2_;
68 double sum11_ = 0;
69 double sumW_ = 0;
70};
71
73
74} // namespace MR
#define MRMESH_API
Definition MRMeshFwd.h:80
unsafe void add(in MR.Vector3d p1, in MR.Vector3d p2, double? w=null)
Definition MRCameraOrientationPlugin.h:8
static MR.Matrix3d zero()