Skip to content

Commit

Permalink
AP_Math: Add is_all_nan
Browse files Browse the repository at this point in the history
* Used when the whole vector being NaN is significant

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
  • Loading branch information
Ryanf55 committed Feb 5, 2024
1 parent c9d878e commit 76348e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libraries/AP_Math/vector3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ bool Vector3<T>::is_nan(void) const
return isnan(x) || isnan(y) || isnan(z);
}

template <typename T>
bool Vector3<T>::is_all_nan(void) const
{
return isnan(x) && isnan(y) && isnan(z);
}

template <typename T>
bool Vector3<T>::is_inf(void) const
{
Expand Down
3 changes: 3 additions & 0 deletions libraries/AP_Math/vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ class Vector3
// check if any elements are NAN
bool is_nan(void) const WARN_IF_UNUSED;

// check if all elements are NAN
bool is_all_nan(void) const WARN_IF_UNUSED;

// check if any elements are infinity
bool is_inf(void) const WARN_IF_UNUSED;

Expand Down

0 comments on commit 76348e0

Please sign in to comment.