Fast uniformly distributed random points on the surface of a unit hemisphere

前端 未结 7 1042
天涯浪人
天涯浪人 2020-12-15 18:26

I am trying to generate uniform random points on the surface of a unit sphere for a Monte Carlo ray tracing program. When I say uniform I mean the points are uniformly distr

7条回答
  •  时光取名叫无心
    2020-12-15 18:50

    Have you tried getting rid of asin?

    azimuthal = 2*PI*dsfmt_genrand_close_open(&dsfmtt);
    sin2_zenith = dsfmt_genrand_close_open(&dsfmtt);
    sin_zenith = sqrt(sin2_zenith);
    
    // Calculate the cartesian point
    osRay.c._x = sin_zenith*cos(azimuthal); 
    osRay.c._y = sin_zenith*sin(azimuthal);
    osRay.c._z = sqrt(1 - sin2_zenith);
    

提交回复
热议问题