Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Random spherical troubles

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25184] Re: Random spherical troubles
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Tue, 12 Sep 2000 21:24:27 -0400 (EDT)
  • References: <8pkl8u$m80@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Barbara,

Noting that cylindrical projection preserves area we get, for a unit sphere,

randomOnCylinder[n_] :=
  Table[{Random[Real, {0, 2N[Pi]}], Random[Real, {-1, 1}]}, {n}]

toSphere[{a_, z_}] :=
  {#Cos[a], # Sin[a], z} &[Sqrt[1 - z^2]]


randomOnSphere[n_] :=
  toSphere /@ randomOnCylinder[n]

Show[Graphics3D[Point /@ randomOnSphere[500]]]



--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Barbara DaVinci" <barbara_79_f at yahoo.it> wrote in message
news:8pkl8u$m80 at smc.vnet.net...
> Hi MathGrouppisti
>
>  This time, my problem is to generate a set of
> directions randomly
>  distributed over the whole solid angle.
>
>  This simple approach is incorrect (spherical
> coordinates are assumed) :
>
>  Table[{Pi Random[], 2 Pi Random[]} , {100}]
>
>  because this way we obtain a set of point uniformly
> distributed
>  over the [0 Pi] x [0 2Pi] rectangle NOT over a
> spherical surface :-(
>
>  If you try doing so and plot the points {1,
> random_theta , random_phi}
>  you will see them gathering around the poles because
> that simple
>  transformation from rectangle to sphere isn't
> "area-preserving" .
>
>  Such a set is involved in a simulation in statistical
>  mechanics ...
>  and I can't get out this trouble.
>
>  May be mapping [0 Pi] x [0 2Pi] in itself , using an
> suitable
>  "non-identity" transformation, can spread points in a
> way balancing
>  the poles clustering effect.
>
>
> ====================================================================
>
>  While I was brooding over that, an intuition flashed
> trought my mind :
>  since spherical to cartesian transformation is
>
>   x = rho Sin[ theta ] Cos[ phi ]
>   y = rho Sin[ theta ] Sin[ phi ]
>   z = rho Cos[ theta ]
>
>  perhaps the right quantities to randomly spread
> around are Cos[ theta ] and
>  Cos[ phi ] rather than theta and phi for itself. Give
> a glance at this :
>
>  Table[{
>  ArcCos[ Random[] ],
>  ArcCos[ Random[] Sign[ 0.5 - Random[] ]
>  } , {100}]
>
>  Do you think it is close to the right ? Do you see a
> better way ?
>  Have you just done the job in the past ? Should I
> reinvent the wheel ?
>
>
> ====================================================================
>
>
>  I thanks you all for prior replies and in advance
> this time.
>
>  Distinti Saluti
>  (read : "Faithfully yours")
>
>  Barbara Da Vinci
>  barbara_79_f at yahoo.it
>
>
>
> ______________________________________________________________________
> Do You Yahoo!?
> Il tuo indirizzo gratis e per sempre @yahoo.it su http://mail.yahoo.it
>




  • Prev by Date: Re: Random spherical troubles
  • Next by Date: Re: Random spherical troubles
  • Previous by thread: Re: Random spherical troubles
  • Next by thread: Re: Random spherical troubles