diff --git a/src/modm/math/geometry/vector3.hpp b/src/modm/math/geometry/vector3.hpp index 10c270d4a1..42beae4813 100644 --- a/src/modm/math/geometry/vector3.hpp +++ b/src/modm/math/geometry/vector3.hpp @@ -205,7 +205,7 @@ namespace modm template static inline Vector operator * (const Matrix &lhs, const Vector &rhs) { - return lhs * rhs.asTMatrix(); + return lhs * rhs.asMatrix(); } diff --git a/test/modm/math/matrix_vector_test.cpp b/test/modm/math/matrix_vector_test.cpp new file mode 100644 index 0000000000..53a1800800 --- /dev/null +++ b/test/modm/math/matrix_vector_test.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2011, Fabian Greif + * Copyright (c) 2012, Niklas Hauser + * Copyright (c) 2017, Marten + * Copyright (c) 2019, Markus Schmidt + * Copyright (c) 2019, Sebastan Birke + * + * This file is part of the modm project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +// ---------------------------------------------------------------------------- + +#include +#include + +#include "matrix_vector_test.hpp" + +void +MatrixVectorTest::testMatrixVectorMultiplication() +{ + const float_t m[] = { + 5., + 8., + -4., + 6., + 9., + -5., + 4., + 7., + -2. + }; + + const float_t v[] = { + 2., + -3., + 1. + }; + + const modm::Matrix a(m); + const modm::Vector3f b(v); + + modm::Vector3f c = a * b; + + TEST_ASSERT_EQUALS(c[0], -18); + TEST_ASSERT_EQUALS(c[1], -20); + TEST_ASSERT_EQUALS(c[2], -15); + +} diff --git a/test/modm/math/matrix_vector_test.hpp b/test/modm/math/matrix_vector_test.hpp new file mode 100644 index 0000000000..f035c7ab05 --- /dev/null +++ b/test/modm/math/matrix_vector_test.hpp @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2009, Martin Rosekeit + * Copyright (c) 2009-2011, Fabian Greif + * Copyright (c) 2012, Niklas Hauser + * Copyright (c) 2019, Markus Schmidt + * Copyright (c) 2019, Sebastan Birke + * + * This file is part of the modm project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +// ---------------------------------------------------------------------------- + +#include + +class MatrixVectorTest : public unittest::TestSuite +{ +public: + void + testMatrixVectorMultiplication(); +};