raytracer 0.2.2

Toy raytracer in Rust
Documentation
use rand::prelude::*;

use crate::{
    Vec3, vec3, len_sqr
};



/// Returns a random point in unit sphere.
pub fn point_in_sphere() -> Vec3 {
    let mut rng = rand::thread_rng();
    let mut point;

    loop {
        point = vec3!(
            rng.gen::<f32>(),
            rng.gen::<f32>(),
            rng.gen::<f32>()
        );

        if len_sqr!(point) >= 1f32 { break; }
    }

    point
}