POV-Ray : Newsgroups : povray.advanced-users : bounding turbulence : Re: bounding turbulence Server Time
1 Jul 2024 00:44:41 EDT (-0400)
  Re: bounding turbulence  
From: Kenneth
Date: 29 Jan 2010 15:25:00
Message: <web.4b633fe55bb1469f65f302820@news.povray.org>
Leroy Whetstone <lrw### [at] joplincom> wrote:

> What I'm trying to do is scale a turbulent spherical pigment so that it
> fits into a 2 unit square on the z plane. The spherical pattern start at
> one and goes toward zero. What I want to know is a way to calculate the
> minamal point from <0,0,0> where every point farther out will be zero.
> (kind of a bounding box)

Would eval_pigment be a way to do this, inside a #while loop?  (Pure guesswork
on my part, as I *still* haven't gotten around to experimenting with eval.)

Here's some ugly sample code that I just came up with. (Others may need to check
it for any errors I've made.) Not a perfect solution--but if it *works*, then I
see all sorts of uses for it myself! The general idea is to sample your
spherical pigment in a *larger*-than-2X2 box(?) volume at lots of random points,
to eventually find the 'outer edge' of your turbulated pigment; and I guess you
would need to choose which rgb color to evaluate in order to find that distance
limit (say, the red component), assuming that you're looking for the most
distant point where red occurs. It's based on the idea that, if eval_pigment
sees no red at a particular location in space, a red value of zero is returned
for that location. So in essence, it looks for the maximum radius(?) where there
is no more red. (Of course, there may be points all *through* the turbulated
pigment where red falls to zero as well; but the code takes care of that.)

#declare S = seed(27);
#declare number_of_samples = 1000; // or some other good statistical sampling
                                   //value
#declare temp_X = 0; // to set this up as empty
#declare temp_Y = 0; // ditto
#declare temp_Z = 0; // ditto
#declare counter = 1;
#while(counter <= number_of_samples)
#declare location = <2*(rand(S) - .5),2*(rand(S) - .5),2*(rand(S) - .5)>;
//covers only the 2X2 volume--just change the multipliers to cover more space

#declare sample_value = eval_pigment(my_pigment,location) // produces a
                                      // three-component vector, I think.
#if(sample_value.red = 0) // or .x? *Any* time the red color drops to zero.
#if(temp_X < abs(location.x))
#declare temp_X = abs(location.x); // temp_X starts at zero, but will climb to
// some maximum positive value--ignoring any lower positive values each time.

#else // DON'T change 'temp_X'
#end
#if(temp_Y < abs(location.y)) // similar to above
#declare temp_Y = abs(location.y);
#else
#end
#if(temp_Z < abs(location.z)) // similar to above
#declare temp_Z = abs(location.z);
#else
#end
#else // sample_value.red does NOT equal zero, so none of the 'temp' values are
      // changed.
#end // of outer #if
#declare counter = counter + 1;
#end // of #while loop

#declare max_radius = vlength(<temp_X,temp_Y,temp_Z>);

max_radius *should* be the maximum distance (not a vector) that the red color
reaches in space--which can then be used to compute the spherical pigment scale,
to fit it into your 2X2 volume.

Ken


Post a reply to this message

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