Mercurial > hg > orthanc-stone
diff Framework/Toolbox/LinearAlgebra.h @ 165:8d50e6be565d wasm
LinearAlgebra toolbox
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 15 Feb 2018 13:51:29 +0100 |
parents | 8c5b24892ed2 |
children | 4f661e2f7b6c |
line wrap: on
line diff
--- a/Framework/Toolbox/LinearAlgebra.h Wed Feb 14 16:49:43 2018 +0100 +++ b/Framework/Toolbox/LinearAlgebra.h Thu Feb 15 13:51:29 2018 +0100 @@ -52,6 +52,9 @@ const Orthanc::DicomTag& tag); void AssignVector(Vector& v, + double v1); + + void AssignVector(Vector& v, double v1, double v2); @@ -66,6 +69,20 @@ double v3, double v4); + Vector CreateVector(double v1); + + Vector CreateVector(double v1, + double v2); + + Vector CreateVector(double v1, + double v2, + double v3); + + Vector CreateVector(double v1, + double v2, + double v3, + double v4); + inline bool IsNear(double x, double y, double threshold) @@ -99,6 +116,74 @@ void Convert(Matrix& target, const Vector& source); + inline Matrix Transpose(const Matrix& a) + { + return boost::numeric::ublas::trans(a); + } + + + inline Matrix IdentityMatrix(size_t size) + { + return boost::numeric::ublas::identity_matrix<double>(size); + } + + + inline Matrix ZeroMatrix(size_t size1, + size_t size2) + { + return boost::numeric::ublas::zero_matrix<double>(size1, size2); + } + + + inline Matrix Product(const Matrix& a, + const Matrix& b) + { + return boost::numeric::ublas::prod(a, b); + } + + + inline Vector Product(const Matrix& a, + const Vector& b) + { + return boost::numeric::ublas::prod(a, b); + } + + + inline Matrix Product(const Matrix& a, + const Matrix& b, + const Matrix& c) + { + return Product(a, Product(b, c)); + } + + + inline Matrix Product(const Matrix& a, + const Matrix& b, + const Matrix& c, + const Matrix& d) + { + return Product(a, Product(b, c, d)); + } + + + inline Matrix Product(const Matrix& a, + const Matrix& b, + const Matrix& c, + const Matrix& d, + const Matrix& e) + { + return Product(a, Product(b, c, d, e)); + } + + + inline Vector Product(const Matrix& a, + const Matrix& b, + const Vector& c) + { + return Product(Product(a, b), c); + } + + double ComputeDeterminant(const Matrix& a); bool IsOrthogonalMatrix(const Matrix& q, @@ -127,5 +212,18 @@ void InvertMatrix(Matrix& target, const Matrix& source); + + void CreateSkewSymmetric(Matrix& s, + const Vector& v); + + void AlignVectorsWithRotation(Matrix& r, + const Vector& a, + const Vector& b); + + Matrix InvertScaleTranslationMatrix(const Matrix& t); + + bool IsShearMatrix(const Matrix& shear); + + Matrix InvertShearMatrix(const Matrix& shear); }; }