From 29959d8cf5e78ca6eef1916010a254f0c6ef6629 Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Mon, 30 Mar 2020 19:04:26 +0200 Subject: [PATCH] VectorT: Implement .cross() and .dot() methods. Aliases for operators % and | for better compatibility with Eigen3. --- src/OpenMesh/Core/Geometry/Vector11T.hh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/Geometry/Vector11T.hh b/src/OpenMesh/Core/Geometry/Vector11T.hh index c11a77e9..44258377 100644 --- a/src/OpenMesh/Core/Geometry/Vector11T.hh +++ b/src/OpenMesh/Core/Geometry/Vector11T.hh @@ -369,7 +369,7 @@ class VectorT { } /// cross product: only defined for Vec3* as specialization - /// \see OpenMesh::cross + /// \see OpenMesh::cross and .cross() template auto operator% (const VectorT &_rhs) const -> typename std::enable_if + auto cross (const VectorT &_rhs) const -> + decltype(*this % _rhs) + { + return *this % _rhs; + } + + /// compute scalar product - /// \see OpenMesh::dot + /// \see OpenMesh::dot and .dot() template auto operator|(const VectorT& _rhs) const -> decltype(*this->data() * *_rhs.data()) { @@ -392,6 +402,15 @@ class VectorT { *begin() * *_rhs.begin()); } + /// compute scalar product + /// \see OpenMesh::dot and .operator| + template + auto dot(const VectorT& _rhs) const -> + decltype(*this | _rhs) + { + return *this | _rhs; + } + //------------------------------------------------------------ euclidean norm /// \name Euclidean norm calculations