mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 06:01:36 +08:00
Vector: Additional normalization with check for zero norm because it occurs so many times in applications
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user