From 4c1608378a79d62d239cb9c6270832720bde57c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 16 Feb 2013 20:12:35 +0100 Subject: [PATCH] Math: document that Quaternion::rotationAxis() might return NaN vector. --- src/Math/Quaternion.h | 4 +++- src/Math/Test/QuaternionTest.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Math/Quaternion.h b/src/Math/Quaternion.h index 47c4f3991..be49ec335 100644 --- a/src/Math/Quaternion.h +++ b/src/Math/Quaternion.h @@ -170,7 +170,9 @@ template class Quaternion { /** * @brief Rotation axis of unit quaternion * - * Expects that the quaternion is normalized. @f[ + * Expects that the quaternion is normalized. Returns either unit-length + * vector for valid rotation quaternion or NaN vector for + * default-constructed quaternion. @f[ * \boldsymbol a = \frac{\boldsymbol q_V}{\sqrt{1 - q_S^2}} * @f] * @see rotationAngle(), rotation() diff --git a/src/Math/Test/QuaternionTest.cpp b/src/Math/Test/QuaternionTest.cpp index cfd6686eb..079c0b755 100644 --- a/src/Math/Test/QuaternionTest.cpp +++ b/src/Math/Test/QuaternionTest.cpp @@ -213,6 +213,10 @@ void QuaternionTest::rotation() { CORRADE_COMPARE(q2, Quaternion(Vector3(-0.5f, -0.5f, -0.5f), 0.5f)); CORRADE_COMPARE(q2.rotationAngle(), deg(120.0f)); CORRADE_COMPARE(q2.rotationAxis(), -axis); + + /* Default-constructed quaternion has zero angle and NaN axis */ + CORRADE_COMPARE(Quaternion().rotationAngle(), deg(0.0f)); + CORRADE_VERIFY(Quaternion().rotationAxis() != Quaternion().rotationAxis()); } void QuaternionTest::angle() {