POV-Ray : Newsgroups : povray.general : Star night sky : Re: Star night sky Server Time
8 Aug 2024 22:11:22 EDT (-0400)
  Re: Star night sky  
From: Warp
Date: 28 Sep 2000 10:04:53
Message: <39d35005@news.povray.org>
Gail Shaw <gsh### [at] monotixcoza> wrote:
:  sphere {
:    <1000,0,0>,1   // change numbers according to scale of scene

:    rotate <360*rand(rndPos),360*rand(rndPos),360*rand(rndPos)>

  This has two main problems.

  Firstly, the sphere is located in the x-axis (at <1000,0,0>), so the
first rotation (which is around the x-axis) will have no effect.

  Secondly, rotating an evenly random angle around the y-axis and then
an evenly random angle around the z-axis has an undesired effect: You
will have more stars near the y-axis (ie. around <0,1000,0>) than near
the x-z plane.
  That is, the stars are not evenly scattered around the sky but there are
more stars directly "up" than near the "horizon".

  If you want an even distribution of stars you have to use a bit more
complicated algorithm. For example:
  1) Calculate a random point inside a sphere (eg. a unit sphere). The
random distribution must be even.
  2) Translate this point in the direction origin-point (ie. multiply it by
a value) so that its distance from the origin will be the desired (eg. 1000).

  For example something like this:

#declare Stars = 1000;
#declare Distance = 1000;
#declare StarRadius = 1;
#declare Seed=seed(0);

#local Ind=0;
#while(Ind<Stars)
  #local Location = <-1+rand(Seed)*2, -1+rand(Seed)*2, -1+rand(Seed)*2>;
  #while(vlength(Location) > 1)
    #local Location = <-1+rand(Seed)*2, -1+rand(Seed)*2, -1+rand(Seed)*2>;
  #end
  #local Location = Distance*Location/vlength(Location);
  sphere { Location, StarRadius pigment { rgb 1 } finish { ambient 1 } }
  #local Ind=Ind+1;
#end

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.