AP_Math: Moves rand_vec3f from SITL_State.

This commit is contained in:
Miguel Arroyo 2017-06-21 13:39:07 -04:00 committed by Andrew Tridgell
parent 86b9942d51
commit 7cea21afa2
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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);