random vector

Started by
23 comments, last by quasar3d 20 years, 5 months ago
Ok, I plugged DarkWing's algorithm into Maple and I have to stand corrected. Its results are indeed uniform. The Maple 7 source is here if anyone wants it.

And I can now see why it is uniform. While it is very similar to the two angle method, there is a critical difference. In this method the z is chosen uniformly. In the two angle method, an angle phi is chosen uniformly, and from it you get z=cos(phi), so that z is clearly not uniform.



[edited by - Mastaba on November 10, 2003 9:40:41 AM]
.
Advertisement
quote:Original post by Geoff the Medio
quote:Original post by quasar3d
I''ve thought about that too, but I tried it out, and it looks very uniform

Did you try plotting the simple point-in-a-cube and normalize method? Was there a noticable concentration of points corresponding to corners of the cube? I''m just wondering if you have enough points to notice the difference...


Yes, I''ve tried that too, and you can really notice concentrations around the corners and edges

My Site
I was thinking though the implications of darkwing's method being uniform is. If z is just a random number, then it implies that the SA of a spherical cap is independant of its position (a & b) in the sphere, it is just dependant on the radius of the sphere and the width of the gap!
If you scroll down to the bottom of the link, it states just that. Am I the only one who finds this striking?

EDIT: Wow, this is even more surprising. I am kicking myself I have not already heard it:http://mathworld.wolfram.com/ArchimedesHat-BoxTheorem.html

[edited by - sadwanmage on November 10, 2003 2:16:17 PM]
I got my function from here : http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-RandomUnitVectors&forum=cotd&id=-1

There is a (long) discussion why and how it works.

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
i see you guys have almost totally dissed the first method for plotting random points on a sphere. if you forgot what the first method was, it was this:
x = rand();
y = rand();
z = rand();

then normalize, then multiply by radius. Here's a screenshot of an old space game I made . you are inside a sphere, the stars were generated almost exactly the same as above, except I did:
x = rand() - rand();
y = rand() - rand();
z = rand() - rand();
then nromalize, and mult by radius. this gives aesthetically pleasing, and it's easier than the spherical coordinates based on the two angles.

http://cboard.cprogramming.com/showthread.php?s=&threadid=37664


and here's another picture that gives you an outside of the sphere view, it's a little dimmer


http://cboard.cprogramming.com/showthread.php?s=&threadid=36607




[edited by - Shadow12345 on November 13, 2003 6:15:54 PM]
Why don't alcoholics make good calculus teachers?Because they don't know their limits!Oh come on, Newton wasn't THAT smart...

This topic is closed to new replies.

Advertisement