Browse Source

AP_Math: Moves rand_vec3f from SITL_State.

mission-4.1.18
Miguel Arroyo 8 years ago committed by Andrew Tridgell
parent
commit
7cea21afa2
  1. 11
      libraries/AP_Math/AP_Math.cpp
  2. 2
      libraries/AP_Math/AP_Math.h

11
libraries/AP_Math/AP_Math.cpp

@ -218,4 +218,15 @@ float rand_float(void) @@ -218,4 +218,15 @@ float rand_float(void)
{
return ((((unsigned)random()) % 2000000) - 1.0e6) / 1.0e6;
}
Vector3f rand_vec3f(void)
{
Vector3f v = Vector3f(rand_float(),
rand_float(),
rand_float());
if (v.length() != 0.0f) {
v.normalize();
}
return v;
}
#endif

2
libraries/AP_Math/AP_Math.h

@ -246,3 +246,5 @@ uint16_t get_random16(void); @@ -246,3 +246,5 @@ 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
Vector3f rand_vec3f(void);

Loading…
Cancel
Save