Merge branch 'vector-cross-method' into 'master'

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

See merge request OpenMesh/OpenMesh!256
This commit is contained in:
Jan Möbius
2020-04-20 08:00:10 +02:00
2 changed files with 47 additions and 5 deletions

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