Skip to content

Commit 733c0e8

Browse files
committed
new method retract
1 parent 1db8dda commit 733c0e8

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/adjustment.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ using Eigen::MatrixXd;
5656
using Eigen::Matrix3d;
5757
using Eigen::SparseMatrix;
5858
using Eigen::Matrix;
59+
using Eigen::Vector;
5960

6061
using Geometry::Rot_ab;
6162

@@ -69,11 +70,27 @@ using TextColor::green;
6970
using TextColor::red;
7071

7172

72-
//! update of parameters (observations) via retraction
73-
void AdjustmentFramework::update( const VectorXd &x)
73+
namespace {
74+
75+
template <int N>
76+
void retract(Eigen::Ref<Vector<double,N> > p,
77+
const Vector<double,N-1> & xr)
7478
{
7579
constexpr double T_zero = 1e-8;
80+
// null(p): N-1 basis vectors for the nullspace of the unit-vector p
81+
const Vector<double,N> v = null<N>(p) * xr;
82+
const double nv = v.norm();
83+
if (nv > T_zero) {
84+
p = std::cos( nv)*p +std::sin(nv)*v/nv;
85+
}
86+
}
87+
88+
} // namespace
7689

90+
91+
//! update of parameters (observations) via retraction
92+
void AdjustmentFramework::update( const VectorXd &x)
93+
{
7794
for (Index s=0; s<x.size()/2; s++) {
7895
const Index idx3 = 3*s;
7996

@@ -83,15 +100,11 @@ void AdjustmentFramework::update( const VectorXd &x)
83100
// m.segment(idx3,3).normalize();
84101

85102
// (2) via retraction ......................................................
86-
const Vector3d p = l0_.segment(idx3,3);
87-
const Vector3d v = null(p) * x.segment(2 * s, 2);
88-
const double nv = v.norm();
89-
if ( nv > T_zero ) {
90-
l0_.segment( idx3,3) = cos( nv)*p +sin(nv)*v/nv;
91-
}
103+
retract<3>(l0_.segment<3>(idx3), x.segment<2>(2*s));
92104
}
93105
}
94106

107+
95108
bool AdjustmentFramework::enforceConstraints( const QVector<std::shared_ptr<ConstraintBase> > & constr,
96109
const IncidenceMatrix & relsub,
97110
const ArrayXi & mapc,
@@ -343,8 +356,8 @@ void AdjustmentFramework::checkConstraints(
343356
const QString msg2 = QStringLiteral("check = %2, \t").arg(d);
344357
QDebug deb = qDebug().noquote();
345358
deb << QStringLiteral("constraint #%1: ").arg(c+1,3);
346-
deb << ( status(c)==Attribute::Required ? green : blue) << msg1 << black;
347-
deb << ( enforced(c) ? black : red) << msg2 << black;
359+
deb << ( status(mapc(c))==Attribute::Required ? green : blue) << msg1 << black;
360+
deb << ( enforced(mapc(c)) ? black : red) << msg2 << black;
348361
}
349362
#endif
350363
}

0 commit comments

Comments
 (0)