Added assert messages to Vector3 functions

This commit is contained in:
Erik Bolumburu 2023-06-29 22:36:44 +01:00 committed by Lukas Dürrenberger
parent b8ca0f6523
commit a143da5f52
2 changed files with 4 additions and 4 deletions

View File

@ -89,9 +89,9 @@ constexpr Vector3<T> Vector3<T>::cwiseMul(const Vector3<T>& rhs) const
template <typename T> template <typename T>
constexpr Vector3<T> Vector3<T>::cwiseDiv(const Vector3<T>& rhs) const constexpr Vector3<T> Vector3<T>::cwiseDiv(const Vector3<T>& rhs) const
{ {
assert(rhs.x != 0); assert(rhs.x != 0 && "Vector3::cwiseDiv() cannot divide by 0");
assert(rhs.y != 0); assert(rhs.y != 0 && "Vector3::cwiseDiv() cannot divide by 0");
assert(rhs.z != 0); assert(rhs.z != 0 && "Vector3::cwiseDiv() cannot divide by 0");
return Vector3<T>(x / rhs.x, y / rhs.y, z / rhs.z); return Vector3<T>(x / rhs.x, y / rhs.y, z / rhs.z);
} }

View File

@ -38,7 +38,7 @@ Vector3<T> Vector3<T>::normalized() const
{ {
static_assert(std::is_floating_point_v<T>, "Vector3::normalized() is only supported for floating point types"); static_assert(std::is_floating_point_v<T>, "Vector3::normalized() is only supported for floating point types");
assert(*this != Vector3<T>()); assert(*this != Vector3<T>() && "Vector3::normalized() cannot normalize a zero vector");
return (*this) / length(); return (*this) / length();
} }