Mercurial > hg > orthanc-stone
changeset 1002:341e68752354
dot product
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 20 Sep 2019 12:00:04 +0200 |
parents | e704a53c9d0a |
children | 1607c4aebc5d |
files | Framework/Toolbox/LinearAlgebra.cpp Framework/Toolbox/LinearAlgebra.h |
diffstat | 2 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Toolbox/LinearAlgebra.cpp Fri Sep 20 11:59:54 2019 +0200 +++ b/Framework/Toolbox/LinearAlgebra.cpp Fri Sep 20 12:00:04 2019 +0200 @@ -126,7 +126,6 @@ } } - void CrossProduct(Vector& result, const Vector& u, const Vector& v) @@ -144,6 +143,16 @@ result[2] = u[0] * v[1] - u[1] * v[0]; } + double DotProduct(const Vector& u, const Vector& v) + { + if (u.size() != 3 || + v.size() != 3) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + } + + return (u[0] * v[0] + u[1] * v[1] + u[2] * v[2]); + } void FillMatrix(Matrix& target, size_t rows,
--- a/Framework/Toolbox/LinearAlgebra.h Fri Sep 20 11:59:54 2019 +0200 +++ b/Framework/Toolbox/LinearAlgebra.h Fri Sep 20 12:00:04 2019 +0200 @@ -162,7 +162,9 @@ void CrossProduct(Vector& result, const Vector& u, const Vector& v); - + + double DotProduct(const Vector& u, const Vector& v); + void FillMatrix(Matrix& target, size_t rows, size_t columns,