From fffad183242db08fbd5c6a2c8a05a152ef0dc82a Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 16 Nov 2022 22:21:45 +1100 Subject: [PATCH] AP_Math: remove normalization of random compass Vector3f --- libraries/AP_Math/AP_Math.cpp | 7 ++----- libraries/AP_Math/AP_Math.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libraries/AP_Math/AP_Math.cpp b/libraries/AP_Math/AP_Math.cpp index 8f01efb259..b646f6753c 100644 --- a/libraries/AP_Math/AP_Math.cpp +++ b/libraries/AP_Math/AP_Math.cpp @@ -348,17 +348,14 @@ float rand_float(void) #endif } +// generate a random Vector3f with each value between -1.0 and 1.0 Vector3f rand_vec3f(void) { - Vector3f v { + return Vector3f{ rand_float(), rand_float(), rand_float() }; - if (!v.is_zero()) { - v.normalize(); - } - return v; } #endif diff --git a/libraries/AP_Math/AP_Math.h b/libraries/AP_Math/AP_Math.h index 0abeac0157..59c5836b11 100644 --- a/libraries/AP_Math/AP_Math.h +++ b/libraries/AP_Math/AP_Math.h @@ -325,7 +325,7 @@ uint16_t get_random16(void); // generate a random float between -1 and 1, for use in SITL float rand_float(void); -// generate a random Vector3f of size 1 +// generate a random Vector3f with each value between -1.0 and 1.0 Vector3f rand_vec3f(void); // return true if two rotations are equal