pub fn concentric_sample_disk(u: &Point2f) -> Point2f {
    // map uniform random numbers to $[-1,1]^2$
    let u_offset: Point2f = u * 2.0 as Float - Vector2f { x: 1.0, y: 1.0 };
    // handle degeneracy at the origin
    if u_offset.x == 0.0 as Float && u_offset.y == 0.0 as Float {
        return Point2f::default();
    }
    // apply concentric mapping to point
    let theta: Float;
    let r: Float;
    if u_offset.x.abs() > u_offset.y.abs() {
        r = u_offset.x;
        theta = PI_OVER_4 * (u_offset.y / u_offset.x);
    } else {
        r = u_offset.y;
        theta = PI_OVER_2 - PI_OVER_4 * (u_offset.x / u_offset.y);
    }
    Point2f {
        x: theta.cos(),
        y: theta.sin(),
    } * r
}
/// Uniformly distribute samples over a unit disk.
Uniformly distribute samples over a unit disk.
Uniformly distribute samples over a unit disk .
pub fn concentric_sample_disk(u: &Point2f) -> Point2f {
    // map uniform random numbers to $[-1,1]^2$
    let u_offset: Point2f = u * 2.0 as Float - Vector2f { x: 1.0, y: 1.0 };
    // handle degeneracy at the origin
    if u_offset.x == 0.0 as Float && u_offset.y == 0.0 as Float {
        return Point2f::default();
    }
    // apply concentric mapping to point
    let theta: Float;
    let r: Float;
    if u_offset.x.abs() > u_offset.y.abs() {
        r = u_offset.x;
        theta = PI_OVER_4 * (u_offset.y / u_offset.x);
    } else {
        r = u_offset.y;
        theta = PI_OVER_2 - PI_OVER_4 * (u_offset.x / u_offset.y);
    }
    Point2f {
        x: theta.cos(),
        y: theta.sin(),
    } * r
}
pub fn concentric_sample_disk ( u : & Point2f ) -> Point2f { // map uniform random numbers to $[-1,1]^2$ let u_offset : Point2f = u * 2.0 as Float - Vector2f { x : 1.0 , y : 1.0 } ; // handle degeneracy at the origin if u_offset . x == 0.0 as Float && u_offset . y == 0.0 as Float { return Point2f :: default ( ) ; } // apply concentric mapping to point let theta : Float ; let r : Float ; if u_offset . x . abs ( ) > u_offset . y . abs ( ) { r = u_offset . x ; theta = PI_OVER_4 * ( u_offset . y / u_offset . x ) ; } else { r = u_offset . y ; theta = PI_OVER_2 - PI_OVER_4 * ( u_offset . x / u_offset . y ) ; } Point2f { x : theta . cos ( ) , y : theta . sin ( ) , } * r }
Uniformly distribute samples over a unit disk.
Uniformly distribute samples over a unit disk .
u
&Point2f