# HG changeset patch # User Benjamin Golinvaux # Date 1568973604 -7200 # Node ID 341e68752354f670eb97206dfddf7ce934e5bb9e # Parent e704a53c9d0a5d4b634e59666b00d41d5656fb39 dot product diff -r e704a53c9d0a -r 341e68752354 Framework/Toolbox/LinearAlgebra.cpp --- 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, diff -r e704a53c9d0a -r 341e68752354 Framework/Toolbox/LinearAlgebra.h --- 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,