#ifndef __RANDOM_H__ #define __RANDOM_H__ #include #include "physical_constants.h" __device__ float uniform(curandState *rng, float a=0.0, float b=1.0) { return a + curand_uniform(rng)*(b-a); } __device__ float3 uniform_sphere(curandState *rng) { float theta = uniform(rng, 0, 2*PI); float u = uniform(rng, -1, 1); float c = sqrtf(1-u*u); return make_float3(c*cosf(theta), c*sinf(theta), u); } #endif