blob: 74329da2a9555c4bbf59063759a461513933599c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#ifndef __RANDOM_H__
#define __RANDOM_H__
#include <curand_kernel.h>
#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
|