AP_Math: make rand_vec a little more efficient

This commit is contained in:
Peter Barker
2022-11-17 15:13:34 +11:00
committed by Peter Barker
parent dd8fbad653
commit 406119ed41
+6 -4
View File
@@ -350,10 +350,12 @@ float rand_float(void)
Vector3f rand_vec3f(void)
{
Vector3f v = Vector3f(rand_float(),
rand_float(),
rand_float());
if (!is_zero(v.length())) {
Vector3f v {
rand_float(),
rand_float(),
rand_float()
};
if (!v.is_zero()) {
v.normalize();
}
return v;