MeshLib
 
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
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
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 MRMesh/MRMeshFwd.h:46
Definition MRPointToPointAligningTransform.h:16
MRMESH_API AffineXf3d findBestRigidXfOrthogonalRotationAxis(const Vector3d &ort) const
this version searches for best transformation where rotation is allowed only around axes orthogonal t...
void add(const Vector3f &p1, const Vector3f &p2, float w=1)
Add one pair of points in the set.
Definition MRPointToPointAligningTransform.h:22
double totalWeight() const
returns summed weight of points accumulated so far
Definition MRPointToPointAligningTransform.h:37
MRMESH_API AffineXf3d findBestRigidXf() const
MRMESH_API void add(const PointToPointAligningTransform &other)
Add another two sets of points.
Vector3d centroid2() const
returns weighted centroid of points p2 accumulated so far
Definition MRPointToPointAligningTransform.h:34
Vector3d centroid1() const
returns weighted centroid of points p1 accumulated so far
Definition MRPointToPointAligningTransform.h:31
MRMESH_API void add(const Vector3d &p1, const Vector3d &p2, double w=1)
Add one pair of points in the set.
MRMESH_API AffineXf3d findBestRigidScaleXf() const
this version searches for best rigid body transformation with uniform scaling
void clear()
Clear sets.
Definition MRPointToPointAligningTransform.h:28
MRMESH_API Vector3d findBestTranslation() const
Simplified solution for translational part only.
MRMESH_API AffineXf3d findBestRigidXfFixedRotationAxis(const Vector3d &axis) const
this version searches for best transformation where rotation is allowed only around given axis and wi...
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
Definition MRCameraOrientationPlugin.h:7