POV-Ray : Newsgroups : povray.advanced-users : Manipulating Density Functions Server Time
31 Oct 2024 08:15:36 EDT (-0400)
  Manipulating Density Functions (Message 1 to 3 of 3)  
From: slehar
Subject: Manipulating Density Functions
Date: 24 Jul 2007 11:20:02
Message: <web.46a617d4ef6472d8f75a90cb0@news.povray.org>
I'd like to use density functions in the media of a transparent-surfaced
cylinder, to depict patterns of standing waves in a cylindrical cavity. How
do you manipulate the values of the density function? The available pattern
modifiers don't seem to do what I need.

For example, look at this transparent cylinder containing a sine_wave
function of a gradient in x, depicted as glowing 3-D patterns in red &
green.

// cylinder containing sinusoidal standing waves
cylinder {
  <0.5, 0, 0> <-0.5, 0, 0> 0.2 // cap and end, radius
  hollow                   // must be hollow to accomodate interior
  texture {Container_T}    // texture transparent to see interior
  interior {               // interior
    media {                // media
      intervals 1
      samples 1,1
      emission 1           // emission 1 (glowing)
      density {            // density function
        gradient x         // gradient in x direction
        frequency 4        // spatial frequency (4 cycles)
        sine_wave          // gradient function sine_wave
        color_map {           // color map
          [0 color red 1]     // density 0 maps to red
          [1 color green 1]   // density 1 maps to green
        }
      }
    }
  }
}

That works OK, and makes a pattern like a 4th harmonic standing wave in a
flute. But can you modify that pattern with mathematical manipulations, for
example to subtract 0.5 from each point in the density function, then
multiply by two, so as to shift it from the range 0 to 1 into the range -1
to +1?

Or can you take each point in the density map, and raise its value to some
exponential i.e. p[x,y,z] = exp(p[x,y,z], expVal)?

Or take the square root of each value i.e. p[x,y,z] = sqrt(p[x,y,z])?

Or are density functions necessarily limited to the range 0 to 1?

  Slehar


Post a reply to this message

From: Tom York
Subject: Re: Manipulating Density Functions
Date: 24 Jul 2007 15:05:02
Message: <web.46a64cc8fbdcbb4f7d55e4a40@news.povray.org>
"slehar" <sle### [at] gmailcom> wrote:
> That works OK, and makes a pattern like a 4th harmonic standing wave in a
> flute. But can you modify that pattern with mathematical manipulations, for
> example to subtract 0.5 from each point in the density function, then
> multiply by two, so as to shift it from the range 0 to 1 into the range -1
> to +1?
>
> Or can you take each point in the density map, and raise its value to some
> exponential i.e. p[x,y,z] = exp(p[x,y,z], expVal)?
>
> Or take the square root of each value i.e. p[x,y,z] = sqrt(p[x,y,z])?

You can do this directly without all that tedious mucking about with
waveform tricks and gradients. Scalar functions can be used directly as
patterns (in POV v3.6.1's manual, this is section 3.5.11.15:  "Function as
pattern").

For your sine example I'm guessing the density would look like this:

density {
  function { 0.5 *(1 + sin(y*4*(2*pi))) }
  color_map {
    [0 color red 1]
    [1 color green 1]
  }
}

(Your other examples similarly). The manual states that color_map entries
are clipped to the [0..1] range in section 3.5.1.3 "Color Maps", so the
density is too, although I guess that only matters if you don't use
function {} for the density.

Tom


Post a reply to this message

From: slehar
Subject: Re: Manipulating Density Functions
Date: 25 Jul 2007 08:30:02
Message: <web.46a74221fbdcbb4ff75a90cb0@news.povray.org>
"Tom York" <alp### [at] zubenelgenubi34spcom> wrote:
> You can do this directly without all that tedious mucking about with
> waveform tricks and gradients. Scalar functions can be used directly as
> patterns (in POV v3.6.1's manual, this is section 3.5.11.15:  "Function as
> pattern").
>
> For your sine example I'm guessing the density would look like this:
>
> density {
>   function { 0.5 *(1 + sin(y*4*(2*pi))) }
>   color_map {
>     [0 color red 1]
>     [1 color green 1]
>   }
> }
>

Wow, thanks Tom! That looks like exactly what I am looking for!

I went round and round for days through the documentation and never ran into
that one!

Thanks!

  Steve


Post a reply to this message

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