diff --git a/src/lib/matrix/matrix/Vector.hpp b/src/lib/matrix/matrix/Vector.hpp index 336e31cef8..49607bd6a3 100644 --- a/src/lib/matrix/matrix/Vector.hpp +++ b/src/lib/matrix/matrix/Vector.hpp @@ -66,7 +66,7 @@ public: return v(i, 0); } - Type dot(const MatrixM1 &b) const + inline Type dot(const MatrixM1 &b) const { const Vector &a(*this); Type r(0); @@ -89,13 +89,13 @@ public: return Vector(MatrixM1::operator*(b)); } - Type norm() const + inline Type norm() const { const Vector &a(*this); return Type(matrix::sqrt(a.dot(a))); } - Type norm_squared() const + inline Type norm_squared() const { const Vector &a(*this); return a.dot(a); @@ -111,12 +111,12 @@ public: (*this) /= norm(); } - Vector unit() const + inline Vector unit() const { return (*this) / norm(); } - Vector unit_or_zero(const Type eps = Type(1e-5)) const + inline Vector unit_or_zero(const Type eps = Type(1e-5)) const { const Type n = norm(); @@ -132,12 +132,12 @@ public: return unit(); } - bool longerThan(Type testVal) const + inline bool longerThan(Type testVal) const { return norm_squared() > testVal * testVal; } - Vector sqrt() const + inline Vector sqrt() const { const Vector &a(*this); Vector r; diff --git a/src/lib/matrix/matrix/Vector2.hpp b/src/lib/matrix/matrix/Vector2.hpp index 35ceb7c1ac..bc310f944d 100644 --- a/src/lib/matrix/matrix/Vector2.hpp +++ b/src/lib/matrix/matrix/Vector2.hpp @@ -60,13 +60,13 @@ public: v(1) = other(1); } - Type cross(const Matrix21 &b) const + inline Type cross(const Matrix21 &b) const { const Vector2 &a(*this); return a(0) * b(1, 0) - a(1) * b(0, 0); } - Type operator%(const Matrix21 &b) const + inline Type operator%(const Matrix21 &b) const { return (*this).cross(b); } diff --git a/src/lib/matrix/matrix/Vector3.hpp b/src/lib/matrix/matrix/Vector3.hpp index b67ab39a8b..a37042f9c7 100644 --- a/src/lib/matrix/matrix/Vector3.hpp +++ b/src/lib/matrix/matrix/Vector3.hpp @@ -62,7 +62,7 @@ public: { } - Vector3 cross(const Matrix31 &b) const + inline Vector3 cross(const Matrix31 &b) const { const Vector3 &a(*this); return {a(1) *b(2, 0) - a(2) *b(1, 0), -a(0) *b(2, 0) + a(2) *b(0, 0), a(0) *b(1, 0) - a(1) *b(0, 0)}; @@ -74,32 +74,38 @@ public: inline Vector3 operator+(Vector3 other) const { - return Matrix31::operator+(other); + const Vector3 &a(*this); + return Vector3{a(0) + other(0), a(1) + other(1), a(2) + other(2)}; } inline Vector3 operator+(Type scalar) const { - return Matrix31::operator+(scalar); + const Vector3 &a(*this); + return Vector3{a(0) + scalar, a(1) + scalar, a(2) + scalar}; } inline Vector3 operator-(Vector3 other) const { - return Matrix31::operator-(other); + const Vector3 &a(*this); + return Vector3{a(0) - other(0), a(1) - other(1), a(2) - other(2)}; } inline Vector3 operator-(Type scalar) const { - return Matrix31::operator-(scalar); + const Vector3 &a(*this); + return Vector3{a(0) - scalar, a(1) - scalar, a(2) - scalar}; } inline Vector3 operator-() const { - return Matrix31::operator-(); + const Vector3 &a(*this); + return Vector3{-a(0), -a(1), -a(2)}; } inline Vector3 operator*(Type scalar) const { - return Matrix31::operator*(scalar); + const Vector3 &a(*this); + return Vector3{a(0) *scalar, a(1) *scalar, a(2) *scalar}; } inline Type operator*(Vector3 b) const