POV-Ray : Newsgroups : povray.advanced-users : Manipulating Density Functions : Re: Manipulating Density Functions Server Time
8 Jul 2024 19:29:44 EDT (-0400)
  Re: Manipulating Density Functions  
From: Tom York
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

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