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


I am trying to make the same random number on the surface of the unit area for the Monte Carlo Ray tracing program. When I say uniform, I mean that the numbers are evenly distributed in relation to the surface area. My current method is to calculate a parallel number on the hemisphere, which points in the positive z axis and XI plane in base.

The random point on the hemisphere represents the direction of emission of thermal radiation for a diffuse gray. Emitter

I get the right result when using the following result:

Note: dsfmt will return a random number between * 0 and 1. Azimuthal = 2 * PI * dsfmt_genrand_close_open (& amp; dsfmtt); Xenith = asin (sqrt (dsfmt_genrand_close_open (and dsfmtt)); // cartesian point osRay.c._x = count (sinith) * cos (azimuthal); OsRay.c._y = Sin (zero) * Sin (azimuthal); OsRay.c._z = Kos (zero);

Although it is quite slow and profiling shows that it takes a large part of run time, so I asked for some alternative ways:

MarcGlia1972 Rejection Method

  Do {x1 = 2.0 * dsfmt_genrand_open_open (& amp; dsfmtt) - 1.0; X2 = 2.0 * dsfmt_genrand_open_open (& amp; dsfmtt) -1.0; S = x1 * x1 + x2 * x2; } While (S> 1.0F); OsRay.c._x = 2.0 * x1 * sqrt (1.0-S); OsRay.c._y = 2.0 × x2 * sqrt (1.0-S); OsRay.c._z = abs (1.0-2.0 * S);   

Analytical Cartesian coordinate calculation

  Azimuthal = 2 * PI * dsfmt_genrand_close_open (& amp; dsfmtt); U = 2 * dsfmt_genrand_close_open (and dsfmtt) -1; W = sqrt (1-u * u); OsRay.c._x = w * cos (AZIMuthal); OsRay.c._y = w * sin (azimuthal); OsRay.c._z = Abs (U);   

While these last two methods run the fastest times before, when I use them, I get results, they indicate that they are one on the surface of an area Are not generating the same random digits, but distributive distributions that favor the equator.

In addition, the last two methods give the same final result, though I'm sure they are wrong because I compare it with analytical solution.

Every reference I have found is that these methods produce equal distribution, although I do not get the correct result.

Is there any error in my implementation or have not I got a fundamental idea in the second and third ways?

In fact, for example dimension 3, e ^ (- x ^ 2/2) e ^ (- y ^ 2/2) e ^ (- z ^ 2/2) = e ^ ( - (x ^ 2 + y ^ 2 + z ^ 2) / 2) then it is irreversible to rotate the joint distribution.

This is fast if you use a fast normal distribution generator (either Ziggurat or ratio-of-uniform) and a fast normalized routine ("google for fast inverse square root.") Any transcendental Function calls are not required.

In addition, the marsglia is not equal to half the area. You will have more digits than the correspondence point on the 2D disc by correspondence point

Area And the point is not isometric to find the last time the right (though I have not calculated to make it).

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -