Commit 488ead16 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'mat3x3-mixed-mult-fixed' into 'master'

Matrix3x3: support multiplication of vectors of different type. [Fixed]

See merge request !164
parents 1d0f737c d232276a
......@@ -6,6 +6,7 @@
#include <ACG/Math/VectorT.hh>
#include <algorithm>
#include <cmath>
#include <utility>
#if defined(_MSC_VER) && _MSC_VER < 1900
#define constexpr
......@@ -128,20 +129,26 @@ class Matrix3x3T {
}};
}
constexpr Vec3 operator*(const Vec3 &rhs) const {
return Vec3(
template<typename OtherScalar>
constexpr auto operator*(const VectorT<OtherScalar,3> &rhs) const
-> OpenMesh::VectorT<decltype(std::declval<Scalar>() * rhs[0]), 3>
{
return {
(*this)(0, 0) * rhs[0] + (*this)(0, 1) * rhs[1] + (*this)(0, 2) * rhs[2],
(*this)(1, 0) * rhs[0] + (*this)(1, 1) * rhs[1] + (*this)(1, 2) * rhs[2],
(*this)(2, 0) * rhs[0] + (*this)(2, 1) * rhs[1] + (*this)(2, 2) * rhs[2]
);
};
}
constexpr friend Vec3 operator*(Vec3 v, const Matrix3x3T &rhs) {
return Vec3(
template<typename OtherScalar>
constexpr friend auto operator*(VectorT<OtherScalar,3> v, const Matrix3x3T &rhs)
-> OpenMesh::VectorT<decltype(std::declval<Scalar>() * v[0]), 3>
{
return {
rhs(0, 0) * v[0] + rhs(0, 1) * v[1] + rhs(0, 2) * v[2],
rhs(1, 0) * v[0] + rhs(1, 1) * v[1] + rhs(1, 2) * v[2],
rhs(2, 0) * v[0] + rhs(2, 1) * v[1] + rhs(2, 2) * v[2]
);
};
}
constexpr Matrix3x3T operator*(Scalar c) const {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment