MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / random_in_unit_sphere

Function random_in_unit_sphere

examples/cuda/gpu/path_tracer_gpu/src/math.rs:24–32  ·  view source on GitHub ↗
(state: &mut DefaultRand)

Source from the content-addressed store, hash-verified

22}
23
24pub fn random_in_unit_sphere(state: &mut DefaultRand) -> Vec3 {
25 loop {
26 let p = random_snorm_vec(state);
27 if p.magnitude_squared() >= 1.0 {
28 continue;
29 }
30 return p;
31 }
32}
33
34pub fn reflect(v: Vec3, n: Vec3) -> Vec3 {
35 v - 2.0 * v.dot(n) * n

Callers 1

scatterMethod · 0.85

Calls 1

random_snorm_vecFunction · 0.85

Tested by

no test coverage detected