diff --git a/src/Math/Test/Vector3Test.cpp b/src/Math/Test/Vector3Test.cpp index ec8cf18eb..ef6833074 100644 --- a/src/Math/Test/Vector3Test.cpp +++ b/src/Math/Test/Vector3Test.cpp @@ -41,6 +41,12 @@ void Vector3Test::cross() { QVERIFY(Vector3::cross(a, b) == Vector3(-10, -3, 7)); } +void Vector3Test::axis() { + QVERIFY(Vector3::xAxis(5.0f) == Vector3(5.0f, 0.0f, 0.0f)); + QVERIFY(Vector3::yAxis(6.0f) == Vector3(0.0f, 6.0f, 0.0f)); + QVERIFY(Vector3::zAxis(7.0f) == Vector3(0.0f, 0.0f, 7.0f)); +} + void Vector3Test::debug() { ostringstream o; Debug(&o) << Vector3(0.5f, 15.0f, 1.0f); diff --git a/src/Math/Test/Vector3Test.h b/src/Math/Test/Vector3Test.h index 69fa9d6e9..50a7b7a86 100644 --- a/src/Math/Test/Vector3Test.h +++ b/src/Math/Test/Vector3Test.h @@ -25,6 +25,7 @@ class Vector3Test: public QObject { private slots: void construct(); void cross(); + void axis(); void debug(); }; diff --git a/src/Math/Vector3.h b/src/Math/Vector3.h index 7b7631548..00427cd17 100644 --- a/src/Math/Vector3.h +++ b/src/Math/Vector3.h @@ -37,13 +37,13 @@ template class Vector3: public Vector { } /** @brief Vector in direction of X axis */ - inline constexpr static Vector3 xAxis(T length = 1) { return Vector3(length, 0, 0); } + inline constexpr static Vector3 xAxis(T length = T(1)) { return Vector3(length, T(), T()); } /** @brief Vector in direction of Y axis */ - inline constexpr static Vector3 yAxis(T length = 1) { return Vector3(0, length, 0); } + inline constexpr static Vector3 yAxis(T length = T(1)) { return Vector3(T(), length, T()); } /** @brief Vector in direction of Z axis */ - inline constexpr static Vector3 zAxis(T length = 1) { return Vector3(0, 0, length); } + inline constexpr static Vector3 zAxis(T length = T(1)) { return Vector3(T(), T(), length); } /** @brief Cross product */ constexpr static Vector3 cross(const Vector3& a, const Vector3& b) {