diff --git a/src/SFML/System/Vector2.cpp b/src/SFML/System/Vector2.cpp index 397ea8ae..b78f0681 100644 --- a/src/SFML/System/Vector2.cpp +++ b/src/SFML/System/Vector2.cpp @@ -38,7 +38,7 @@ Vector2 Vector2::normalized() const { static_assert(std::is_floating_point_v, "Vector2::normalized() is only supported for floating point types"); - assert(*this != Vector2()); + assert(*this != Vector2() && "Vector2::normalized() cannot normalize a zero vector"); return (*this) / length(); } @@ -49,8 +49,8 @@ Angle Vector2::angleTo(const Vector2& rhs) const { static_assert(std::is_floating_point_v, "Vector2::angleTo() is only supported for floating point types"); - assert(*this != Vector2()); - assert(rhs != Vector2()); + assert(*this != Vector2() && "Vector2::angleTo() cannot calculate angle from a zero vector"); + assert(rhs != Vector2() && "Vector2::angleTo() cannot calculate angle to a zero vector"); return radians(static_cast(std::atan2(cross(rhs), dot(rhs)))); } @@ -61,7 +61,7 @@ Angle Vector2::angle() const { static_assert(std::is_floating_point_v, "Vector2::angle() is only supported for floating point types"); - assert(*this != Vector2()); + assert(*this != Vector2() && "Vector2::angle() cannot calculate angle from a zero vector"); return radians(static_cast(std::atan2(y, x))); } @@ -87,7 +87,7 @@ Vector2 Vector2::projectedOnto(const Vector2& axis) const { static_assert(std::is_floating_point_v, "Vector2::projectedOnto() is only supported for floating point types"); - assert(axis != Vector2()); + assert(axis != Vector2() && "Vector2::projectedOnto() cannot project onto a zero vector"); return dot(axis) / axis.lengthSq() * axis; }