Browse Source

Documentation clarification, assertion update.

Don't yell at the user all the time.
pull/279/head
Vladimír Vondruš 14 years ago
parent
commit
03f135e696
  1. 2
      src/Math/Test/VectorTest.cpp
  2. 6
      src/Math/Vector.h

2
src/Math/Test/VectorTest.cpp

@ -110,7 +110,7 @@ void VectorTest::angle() {
Error::setOutput(&o);
/* Both vectors must be normalized, otherwise NaN is returned */
CORRADE_COMPARE(Vector3::angle(Vector3(2.0f, 3.0f, 4.0f).normalized(), {1.0f, -2.0f, 3.0f}), numeric_limits<Vector3::Type>::quiet_NaN());
CORRADE_COMPARE(o.str(), "Math::Vector::angle(): vectors must be normalized!\n");
CORRADE_COMPARE(o.str(), "Math::Vector::angle(): vectors must be normalized\n");
CORRADE_COMPARE(Vector3::angle({2.0f, 3.0f, 4.0f}, Vector3(1.0f, -2.0f, 3.0f).normalized()), numeric_limits<Vector3::Type>::quiet_NaN());
CORRADE_COMPARE(Vector3::angle(Vector3(2.0f, 3.0f, 4.0f).normalized(), Vector3(1.0f, -2.0f, 3.0f).normalized()), rad(1.162514f));

6
src/Math/Vector.h

@ -85,12 +85,12 @@ template<size_t s, class T> class Vector: public RectangularMatrix<1, s, T> {
* @f[
* \phi = \frac{a \cdot b}{|a| \cdot |b|}
* @f]
* @attention If any of the parameters is not normalized (and
* assertions are enabled), returns NaN.
* @attention Assertion fails on non-normalized vectors and NaN is
* returned.
*/
inline static T angle(const Vector<size, T>& a, const Vector<size, T>& b) {
CORRADE_ASSERT(MathTypeTraits<T>::equals(a.dot(), T(1)) && MathTypeTraits<T>::equals(b.dot(), T(1)),
"Math::Vector::angle(): vectors must be normalized!", std::numeric_limits<T>::quiet_NaN());
"Math::Vector::angle(): vectors must be normalized", std::numeric_limits<T>::quiet_NaN());
return std::acos(dot(a, b));
}

Loading…
Cancel
Save