0

Hi,

I need to generate a 'uniform sample' over an hemisphere and once done project it in a specific vector direction.

I have try the following, but it produce some errors... maybe you have an idea ? I have another solution, but I don't understand why this one does not work !

1. Create a random direction

x = random() * 2 - 1

y = random() * 2 - 1

z = random() * 2 - 1

d = normalize(x,y,z) // Scale it to have vector lenght = 1

2. Project the sample into the direction

dp = dot_product(d, direction)

if dp <= 0 then result = -d

else result = d

Thanks

flag
1 
Your random vector $(x,y,z)$ is not distributed correctly. mathworld.wolfram.com/SpherePointPicking.html – Dan Petersen Jul 17 at 9:10

closed as off topic by Dan Petersen, Ricky Demer, Henry Cohn, Andy Putman, Kate Juschenko Jul 18 at 19:36

1 Answer

1

This is fully discussed in

http://mathoverflow.net/questions/24688

link|flag
Thanks, I have read it both references. I already use one of the solution in the Wolfram reference (this one works of course). But, the solution that does not work for me is the last of from the Wolfram link, formula (16). So, it should work ! – spectral Jul 17 at 9:39
I use simple random numbers that I scale between [-1,1] like this : (rnd*2-1) – spectral Jul 17 at 9:40
2 
In the last variant in the Wolfram link you're supposed to use normally distributed random variables, yours are not. In any case, your questions are off topic on this site, which is about research level mathematics question. In the future you would be better off asking at math.stackexchange.com – Dan Petersen Jul 17 at 9:55
Thanks, Why my random values are not "normally distributed" ? – spectral Jul 17 at 10:02
1 
For a reason that won't be given here, since the question is off topic. $\:$ (See Dan's comment.) – Ricky Demer Jul 17 at 10:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.