From 39340e70f86f362d10d2fe21d1cb06080d5870c8 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Tue, 15 Sep 2015 15:53:44 +0900 Subject: [PATCH] Math: add Vector2 is_zero method --- libraries/AP_Math/vector2.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/AP_Math/vector2.h b/libraries/AP_Math/vector2.h index 9cdd8ab604..c599ed6496 100644 --- a/libraries/AP_Math/vector2.h +++ b/libraries/AP_Math/vector2.h @@ -105,6 +105,9 @@ struct Vector2 // check if any elements are infinity bool is_inf(void) const; + // check if all elements are zero + bool is_zero(void) const { return (fabsf(x) < FLT_EPSILON) && (fabsf(y) < FLT_EPSILON); } + // zero the vector void zero() {