diff 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
line wrap: on
line diff
--- a/Framework/Toolbox/LinearAlgebra.cpp	Fri Nov 09 17:41:46 2018 +0100
+++ b/Framework/Toolbox/LinearAlgebra.cpp	Fri Nov 09 17:59:35 2018 +0100
@@ -206,9 +206,15 @@
     {
       // https://en.wikipedia.org/wiki/Orthogonal_matrix
 
+      if (q.size1() != q.size2())
+      {
+        LOG(ERROR) << "An orthogonal matrix must be squared";
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+      }
+
       using namespace boost::numeric::ublas;
 
-      const Matrix check = prod(trans(q), q) - identity_matrix<double>(3);
+      const Matrix check = prod(trans(q), q) - identity_matrix<double>(q.size1());
 
       type_traits<double>::real_type norm = norm_inf(check);
 
@@ -522,7 +528,10 @@
     void CreateSkewSymmetric(Matrix& s,
                              const Vector& v)
     {
-      assert(v.size() == 3);
+      if (v.size() != 3)
+      {
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+      }
 
       s.resize(3, 3);
       s(0,0) = 0;