Browse Source

Vector: Additional normalization with check for zero norm because it occurs so many times in applications

master
Matthias Grob 7 years ago
parent
commit
9e59691e43
  1. 8
      matrix/Vector.hpp

8
matrix/Vector.hpp

@ -83,6 +83,14 @@ public: @@ -83,6 +83,14 @@ public:
return (*this) / norm();
}
Vector unit_or_zero(const Type eps = 1e-5f) {
const Type n = norm();
if (n > eps) {
return (*this) / n;
}
return Vector();
}
inline Vector normalized() const {
return unit();
}

Loading…
Cancel
Save