[Date Index]
[Thread Index]
[Author Index]
Re:Random spherical troubles
*To*: mathgroup at smc.vnet.net
*Subject*: [mg25197] Re:[mg25170] Random spherical troubles
*From*: Ranko Bojanic <rbojanic at columbus.rr.com>
*Date*: Tue, 12 Sep 2000 21:24:41 -0400 (EDT)
*Organization*: Ohio State University
*Sender*: owner-wri-mathgroup at wolfram.com
On September 12,2000 Barbara DaVinci<barbara_79_f at yahoo.it> wrote:
> ........
> my problem is to generate a set of directions randomly distributed
> over the whole solid angle
> ......
Ciao Barbara:
In Donald E. Knuth's The Art of Computer Programming (Third Edition),
I found on p. 135 a section on Random points on an n-dimensional
sphere with radius one. If I have understood correctly that section,
uniformly distributed points on the surface of the unit sphere in the
first octant can be obtained as follows: Take 3 uniformly distributed
variables x, y and z in [0,1] and form the point
{x,y,z,}/Sqrt[x^2+y^2+z^2]. In Mathematica this can be implemented by
rPt3D := Module[{x = Random[], y = Random[], z = Random[]},
Return[{x,y,z}/Sqrt[x^2+y^2+z^2]]]
pts[n_]:= Table[Point[rPt3D],{n}];
To see thousand random points on the surface of the unit sphere, in the
first octant, use
Show[Graphics3D[pts[1000],ViewPoint -> { 4,4,6}]];
A similar method would be this one: select at random x and y in [0,1]
until you get x, y such that x^2+y^2 <= 1.The point
{x,y,Sqrt[1-x^2-y^2]}
will be then on the surface of the unit sphere. This can be implemented
by
newPt3D := Module[{ x = Random[ ], y = Random[ ]},
While[x^2 + y^2 > 1, x = Random[ ]; y = Random[ ]];
Return[{x,y, Sqrt[1 - x^2 - y^2]}]];
pts[n_]:= Table[Point[newPt3D],{n}];
Show[Graphics3D[pts[1000],ViewPoint ->{ 4,4,6}]];
The points obtained by either one of these two methods appear to be
uniformly distributed on the surface of the unit sphere in the first
octant.
Regards,
Ranko
Prev by Date:
**Re: save a plot**
Next by Date:
**Re: Displaying 3D data as 2D + color ?**
Previous by thread:
**RE: Random spherical troubles**
Next by thread:
**Re: Random spherical troubles**
| |