VectorT: Implement .cross() and .dot() methods.

Aliases for operators % and | for better compatibility with Eigen3.
This commit is contained in:
Martin Heistermann
2020-03-30 19:04:26 +02:00
parent b4cbe27459
commit 29959d8cf5

View File

@@ -369,7 +369,7 @@ class VectorT {
}
/// cross product: only defined for Vec3* as specialization
/// \see OpenMesh::cross
/// \see OpenMesh::cross and .cross()
template<typename OtherScalar>
auto operator% (const VectorT<OtherScalar, DIM> &_rhs) const ->
typename std::enable_if<DIM == 3,
@@ -382,8 +382,18 @@ class VectorT {
};
}
/// cross product: only defined for Vec3* as specialization
/// \see OpenMesh::cross and .operator%
template<typename OtherScalar>
auto cross (const VectorT<OtherScalar, DIM> &_rhs) const ->
decltype(*this % _rhs)
{
return *this % _rhs;
}
/// compute scalar product
/// \see OpenMesh::dot
/// \see OpenMesh::dot and .dot()
template<typename OtherScalar>
auto operator|(const VectorT<OtherScalar, DIM>& _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<typename OtherScalar>
auto dot(const VectorT<OtherScalar, DIM>& _rhs) const ->
decltype(*this | _rhs)
{
return *this | _rhs;
}
//------------------------------------------------------------ euclidean norm
/// \name Euclidean norm calculations