diff --git a/MathLib/Vector3.h b/MathLib/Vector3.h index e86056f20304a8c818d47626d1cc3230b793b5b0..30bb7f3ea88f6932605c1b46636139f931541c8a 100644 --- a/MathLib/Vector3.h +++ b/MathLib/Vector3.h @@ -120,9 +120,10 @@ public: double s, TemplateVector3<T1> const& v); - TemplateVector3& operator*=(double pR) + TemplateVector3& operator*=(double s) { - for (std::size_t i(0); i < 3; i++) this->_x[i] *= pR; + for (std::size_t i(0); i < 3; i++) + this->_x[i] *= s; return *this; } diff --git a/Tests/MathLib/TestVector3.cpp b/Tests/MathLib/TestVector3.cpp index 95fb6b3aa8122f93c3e4a9b6e49b6ef0431a060d..ee62f012b6eb85edb2d2e1ec624fda48b725e1ff 100644 --- a/Tests/MathLib/TestVector3.cpp +++ b/Tests/MathLib/TestVector3.cpp @@ -83,6 +83,13 @@ TEST(MathLib, TestVector3Operators) ASSERT_NEAR(-4.0, res[0], std::numeric_limits<double>::min()); ASSERT_NEAR( 0.0, res[1], std::numeric_limits<double>::min()); ASSERT_NEAR( 4.0, res[2], std::numeric_limits<double>::min()); + + // test operator*= + v *= 2.0; + ASSERT_NEAR(2.0, v[0], std::numeric_limits<double>::min()); + ASSERT_NEAR(6.0, v[1], std::numeric_limits<double>::min()); + ASSERT_NEAR(10.0, v[2], std::numeric_limits<double>::min()); + } TEST(MathLib, TestVector3Multiplications)