POV-Ray : Newsgroups : povray.newusers : plotting a 3D gaussian question : Re: plotting a 3D gaussian question Server Time
2 Jul 2022 07:26:48 EDT (-0400)
  Re: plotting a 3D gaussian question  
From: Alain
Date: 27 Oct 2016 19:41:47
Message: <581290bb$1@news.povray.org>

> "Bald Eagle" <cre### [at] netscapenet> wrote:
>> This ought to do it:
>>
>>
>> #version 3.7;
>>
>> // 3D Gussian isosurface with peak at origin
>> // October 2016, Bald Eagle
>>
>> #include "colors.inc"
>> #include "debug.inc"
>>
>> global_settings {
>>   assumed_gamma 1.0
>> }
>>
>> camera {
>>    location  <5, 10, -30.0>
>>    look_at   <0, 0,  0.0>
>>  right    x*image_width/image_height
>> }
>>
>> light_source { < 10, 20, -50>  color White}
>>
>> // Create an infinite sphere around scene and allow any pigment on it
>> sky_sphere{ pigment { gradient <0,1,0>
>>                       color_map { [0.00 rgb <0.6,0.7,1.0>]
>>                                   [0.35 rgb <0.0,0.1,0.8>]
>>                                   [0.65 rgb <0.0,0.1,0.8>]
>>                                   [1.00 rgb <0.6,0.7,1.0>]
>>                                 }
>>                       scale 2
>>                     } // end of pigment
>>           } //end of skysphere -------------------------------------
>>
>>
>> #declare X0 = 0;
>> #declare Z0 = 0;
>> #declare A = 5;
>> #declare a = 0.5;
>> #declare b = 0;
>> #declare c = 0.5;
>>
>> sphere {<0, 0, 0> 0.25 texture {pigment {Yellow} finish {specular 0.6}} }
>>
>> cylinder {<0, 0, 0>, <10, 0, 0> 0.1 pigment {Red} } // x axis
>> cylinder {<0, 0, 0>, <0, 10, 0> 0.1 pigment {Green} } // y axis
>> cylinder {<0, 0, 0>, <0, 0, 10> 0.1 pigment {Blue} } // z axis
>>
>> #declare Gaussian = function {y - A * exp(   -( a*pow((x-X0),2) -
>> 2*b*(x-X0)*(z-Z0) + c*pow((z-Z0),2) )   ) }
>>
>> isosurface{ //------------------------- "sombrero"
>>   function {Gaussian (x, y, z)}
>>   max_gradient 10    // <=== adjust this if there is a notification in the
>> message window after rendering!
>>  open
>>   threshold 0
>>   contained_by{box{<-10, -0.1, -10>, <10, 5, 10>}}  // make sure your
>> contained_by box is the right size
>>
>>           texture{ pigment{ spiral1 5 rotate<90,0,0>
>>                             color_map{
>>                                 [ 0.0 color rgb<1,1,1> ]
>>                                 [ 0.5 color rgb<1,1,1> ]
>>                                 [ 0.5 color rgb<1,0,0> ]
>>                                 [ 1.0 color rgb<1,0,0> ]
>>                                } // end color_map
>>                              scale 0.5
>>                            } // end pigment
>>                  //normal  { bumps 0.5 scale  0.005 }
>>                    finish  { phong 1 reflection 0.00 }
>>                  } // end of texture ------------------
>>
>>
>>
>>   scale <1, 1, 1>
>>   rotate <0,0,0>
>>   translate <0, -A, 0>
>> } // end of isosurface ----------------
>>
>> box{<-10, -0.1, -10>, <10, 5, 10> pigment {rgbt <1, 1, 1, 0.9>} translate <0,
>> -A, 0>}
>
> Thanks a lot! This worked like a charm. I just have one more problem, now my
> green balls are disappearing behind my gaussian function, if I make it too
> transparent then I wont see the Gaussian. Is there a possibility to make the
> green balls "inside" the gaussian much stronger so they are able to be seen
> through the gaussian ?
>

Replace the rgb keyword by rgbf or rgbt and add a fourth value to the 
colours : rgbf<1,1,1,0.5> or rgbt<1,1,1,0.5>
Play around with the fourth value untill you get a result that you like.
You can also use this form : rgbft<1,1,1,0.3,0.2>
If you use a transmit value of 1, your pigment become totally 
transparent with no hint of colouration. A filter of 1 will always stay 
visible, but rgbf<0,0,0,1> will show an opaque black.

If you get black, or to dark areas, add max_trace_level 10 (or a larger 
value) to your global_settings block.


Post a reply to this message

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