Skip to content

Commit 0485ece

Browse files
committed
method getEntity now template function
1 parent 4b792d4 commit 0485ece

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/adjustment.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include <cmath>
3838
#include <memory>
3939
#include <sstream>
40-
#include <utility>
4140

4241
#include <Eigen/Core>
4342
#include <Eigen/SparseCore>
@@ -70,17 +69,6 @@ using TextColor::green;
7069
using TextColor::red;
7170

7271

73-
std::pair<Vector3d,Matrix3d >
74-
AdjustmentFramework::getEntity( const Index s) const
75-
{
76-
const Index offset = 3*s;
77-
const Matrix3d RR = Rot_ab<double,3>( l_.segment(offset,3),
78-
l0_.segment(offset,3) );
79-
return { l0_.segment(offset,3),
80-
RR*Cov_ll_.block(offset,offset,3,3)*RR.adjoint() };
81-
}
82-
83-
8472
//! update of parameters (observations) via retraction
8573
void AdjustmentFramework::update( const VectorXd &x)
8674
{

src/adjustment.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
#include "qcontainerfwd.h"
3030

31+
#include "geometry/minrot.h"
32+
3133

3234
namespace Constraint {class ConstraintBase;} // namespace Constraint
3335
namespace Graph {class IncidenceMatrix;} // namespace Graph
@@ -64,8 +66,19 @@ class AdjustmentFramework
6466
Eigen::Array<Attribute,Eigen::Dynamic,1> & status,
6567
Eigen::Array<bool,Eigen::Dynamic,1> & enforced);
6668

67-
//! Get s-th entity, i.e., segment, represented by vector of length len
68-
[[nodiscard]] std::pair<Eigen::Vector3d, Eigen::Matrix3d> getEntity( Eigen::Index s) const;
69+
//! Get s-th entity represented by vector of length N
70+
template <int N>
71+
std::pair<Eigen::Vector<double,N>,Eigen::Matrix<double,N,N> >
72+
getEntity( const Eigen::Index s) const
73+
{
74+
const Eigen::Index offset = N*s;
75+
const Eigen::Matrix<double,N,N> RR = Geometry::Rot_ab(
76+
l_.segment(offset,N).eval(),
77+
l0_.segment(offset,N).eval() );
78+
79+
return { l0_.segment(offset,N),
80+
RR*Cov_ll_.block(offset,offset,N,N)*RR.adjoint() };
81+
}
6982

7083
private:
7184
[[nodiscard]] static int nIterMax() { return nIterMax_; }

src/state.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ void impl::update_segments( const ArrayXi & maps_,
823823
{
824824
for ( Index s=0; s<maps_.size(); s++ ) {
825825
// straight line: s-th 3-vector
826-
const std::pair<Vector3d,Matrix3d> p = a.getEntity(s);
826+
const std::pair<Vector3d,Matrix3d> p = a.getEntity<3>(s);
827827
const uStraightLine ul( p.first, p.second );
828828

829829
const uPoint ux = m_segm.at( maps_(s) )->ux();

0 commit comments

Comments
 (0)