comparison Framework/Toolbox/LinearAlgebra.cpp @ 392:d87fe075d31b

to graveyard
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 09 Nov 2018 17:59:35 +0100
parents 5412adf19980
children b70e9be013e4
comparison
equal deleted inserted replaced
391:021480604c92 392:d87fe075d31b
204 bool IsOrthogonalMatrix(const Matrix& q, 204 bool IsOrthogonalMatrix(const Matrix& q,
205 double threshold) 205 double threshold)
206 { 206 {
207 // https://en.wikipedia.org/wiki/Orthogonal_matrix 207 // https://en.wikipedia.org/wiki/Orthogonal_matrix
208 208
209 if (q.size1() != q.size2())
210 {
211 LOG(ERROR) << "An orthogonal matrix must be squared";
212 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
213 }
214
209 using namespace boost::numeric::ublas; 215 using namespace boost::numeric::ublas;
210 216
211 const Matrix check = prod(trans(q), q) - identity_matrix<double>(3); 217 const Matrix check = prod(trans(q), q) - identity_matrix<double>(q.size1());
212 218
213 type_traits<double>::real_type norm = norm_inf(check); 219 type_traits<double>::real_type norm = norm_inf(check);
214 220
215 return (norm <= threshold); 221 return (norm <= threshold);
216 } 222 }
520 526
521 527
522 void CreateSkewSymmetric(Matrix& s, 528 void CreateSkewSymmetric(Matrix& s,
523 const Vector& v) 529 const Vector& v)
524 { 530 {
525 assert(v.size() == 3); 531 if (v.size() != 3)
532 {
533 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
534 }
526 535
527 s.resize(3, 3); 536 s.resize(3, 3);
528 s(0,0) = 0; 537 s(0,0) = 0;
529 s(0,1) = -v[2]; 538 s(0,1) = -v[2];
530 s(0,2) = v[1]; 539 s(0,2) = v[1];