Function gl_utils::graphics::rand_point3d[][src]

pub fn rand_point3d<S, R>(rng: &mut R, aabb: &Aabb3<S>) -> Point3<S> where
    S: BaseFloat + SampleRange,
    R: Rng

Generate a random point contained in the give AABB

use collision::Contains;
use rand::SeedableRng;
// random sequence will be the same each time this is run
let mut rng = rand::XorShiftRng::new_unseeded();
let aabb = collision::Aabb3::<f32>::new (
  [-10.0, -10.0, -10.0].into(),
  [ 10.0,  10.0,  10.0].into());
let point = rand_point3d (&mut rng, &aabb);
assert!(aabb.contains (&point));
let point = rand_point3d (&mut rng, &aabb);
assert!(aabb.contains (&point));
let point = rand_point3d (&mut rng, &aabb);
assert!(aabb.contains (&point));
let point = rand_point3d (&mut rng, &aabb);
assert!(aabb.contains (&point));
let point = rand_point3d (&mut rng, &aabb);
assert!(aabb.contains (&point));