Cosine Weighted Hemisphere
The probability of each sample is weighted by its cosine with the normal.
Here is the result:
function cos_hemisphere(){
const u_1 = Math.random();
const u_2 = Math.random();
// Math.sqrt(u_1) works the same way
const theta = Math.acos(Math.sqrt(1.0 - u_1));
const phi = u_2 * 2.0 * Math.PI;
return [theta,phi];
}
Algorithm
Generate points weighted by the cosine hemisphere.
- Choose uniform numbers in
- Calculate
- Calculate
Optionally convert to cartesian coordinates with:
PDF Used In Monte Carlo Integration
Derivation
This is a special case of the power cosine weighted hemisphere cap with