42 double defaultThreshold = 1e-1;
44 std::vector<mitk::NavigationData::Pointer> _CheckedTransforms;
45 for (
size_t i = 0; i < m_NavigationDatas.size(); ++i)
47 if (!m_NavigationDatas.at(i)->IsDataValid())
49 MITK_WARN <<
"Skipping invalid transform " << i <<
".";
52 _CheckedTransforms.push_back(m_NavigationDatas.at(i));
55 if (_CheckedTransforms.empty())
57 MITK_WARN <<
"Checked Transforms are empty";
61 unsigned int rows = 3 * _CheckedTransforms.size();
62 unsigned int columns = 6;
64 vnl_matrix< double >
A(rows, columns), minusI(3, 3, 0), R(3, 3);
65 vnl_vector< double > b(rows), x(columns), t(3);
72 unsigned int currentRow = 0;
75 for (
size_t i = 0; i < _CheckedTransforms.size(); ++i)
77 t = _CheckedTransforms.at(i)->GetPosition().GetVnlVector();
79 b.update(t, currentRow);
80 R = _CheckedTransforms.at(i)->GetOrientation().rotation_matrix_transpose().transpose().as_ref();
81 A.update(R, currentRow, 0);
82 A.update(minusI, currentRow, 3);
85 vnl_svd<double> svdA(
A);
86 svdA.zero_out_absolute(defaultThreshold);
92 MITK_WARN <<
"svdA.rank() < 6";
99 m_ResultRMSError = (
A * x - b).rms();
102 m_ResultPivotPoint[0] = x[0];
103 m_ResultPivotPoint[1] = x[1];
104 m_ResultPivotPoint[2] = x[2];