POV-Ray : Newsgroups : povray.advanced-users : Stochastics expertise needed : Re: Stochastics expertise needed Server Time
17 May 2024 01:04:39 EDT (-0400)
  Re: Stochastics expertise needed  
From: Bald Eagle
Date: 26 Aug 2016 22:40:00
Message: <web.57c0fd6f8629941b5e7df57c0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> You've hit the nail right on the head :)

Here's my crappy code, but best looking distribution for the day (based on my
abyssmal histograph).

I think it's a matter of defining the function / spline / clustering of the
random vector - everything else looks fairly straightforward.

I especially wanted to avoid the wasteful hit-or-miss style algorithm - so I
made sure every random number returns a "valid" result.

I'd say this looks like a statistics specialty, or given the spherical-based
distribution - a quantum mechanics-type function.

I hope this acts as a first pointer in the right direction.
{I started to struggle right at Theta and Phi.   ;)  :D   }

##############################################################

// spline / sqrt spherical pattern
// Bald Eagle 2016
#version 3.7;

global_settings {assumed_gamma 1.0}

#include "colors.inc"
#include "textures.inc"
#include "rand.inc"


#declare R = 5;


camera {
 location <0, R, -20>
 look_at  <0, R, 0>
 right     x*image_width/image_height
 up y
}


light_source {<20, 50, -100> White shadowless}



#declare Tiny = 0.000001;
#declare Stream = seed (123);
#declare Stream2 = seed (456789);
#declare Stream3 = seed (789);

#declare Sphere_Spline =
  spline {
    linear_spline
   //-0.25, <-0.25, 0.0, 0>,
    0.00, <0.00000000000000000001, 0.0, 0>,
 0.1 <0.9, 0, 0>,
    1.00, <1, 0, 0>
   // 1.1 , <1.1, 0, 0>
  } //-------------------


#declare Samples = 10000;
#declare Histograph = array [60]
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0};

#declare Sphere1 =
union {
    #for (Point, 1, Samples)
        #declare Phi =  RRand(0, 2*pi, Stream);

        #declare Variable2 = RRand(0, 1, Stream2);
        //#declare Variable2 = RRand(1.00000001, 10, Stream2);

  //#declare Theta = (pi*Sphere_Spline(Variable2).x)-(pi/2);
  #declare Theta = (pi*sqrt(Sphere_Spline(Variable2).x))-(pi/2);
        //#declare Theta = (-pi*(1-Sphere_Spline(log(Variable2)).x))+(pi/2);
        //#declare Theta = (-pi*abs(Sphere_Spline(pow(1-log(Variable2),
3)).x))+(pi/2);

    #declare X = R * cos (Theta.x) * sin (Phi);
    #declare Z = R * cos (Theta.x) * cos (Phi);
    #declare Y = R * sin (Theta.x) + R;

 #declare Histograph [int((Y/(2*R))*59)] = Histograph [int((Y/(2*R))*59)]+1;

    sphere {<X, Y, Z>, 0.01 pigment {Red} }
    #end
}



object {Sphere1}

cylinder {<0, 0, 0>, <6, 0, 0>, 0.05 pigment {Blue} }
cylinder {<0, 0, 0>, <0, R, 0>, 0.05 pigment {Blue} }
#for (GraphX, 0, 60-1)
 sphere {<GraphX/10, Histograph[GraphX]/10, 0>, 0.1 pigment {Green}}// translate
-y*R}
#end


Post a reply to this message

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