POV-Ray : Newsgroups : povray.newusers : Problem with using rand : Problem with using rand Server Time
30 Jun 2024 04:15:57 EDT (-0400)
  Problem with using rand  
From: lucas
Date: 16 Oct 2011 10:30:00
Message: <web.4e9aea04ca006560bc426c6c0@news.povray.org>
Hello,

I declared a few functions. I need to use a random generator in one of them.
Accprding to documentation (http://www.povray.org/documentation/view/3.6.1/228/)
I thought that I can use function rand() as any other float function, but I
encountered a problem. I can declare a function like below:

#declare SinFn = function(R) { Ampl*sin(R)/(R + Damp)}

And this works.
When I want to add a rand function for example like below:

#declare SinFn = function(R) { Ampl*rand(seed(90))*sin(R)/(R + Damp)}

I got an error: "Parse Error: Expected 'function identifier', } found instead".
I am a newbie and I don't get it. Why can't I use those functions like others
listed in documentation (sin or cos for example)? What I am doing wrong? Below
you can find a part of my code. My goal is to make this surface look as it was
creased.


#declare Ampl = 5;
#declare Freq = 1.5;
#declare Damp = 0;

#declare SquashFn = function(T, S) { select(S, -0.5, 0.5)*(tanh(abs(S)*T) - 1) }

#declare SinFn = function(R) { Ampl*sin(R)/(R + Damp)}

#declare Fn = function(x, z) { SinFn(Freq*f_r(x, 0, z))}



#declare folia = isosurface {
  function {
    SquashFn(y - Fn(x, z), 10)
  }
  open
  threshold -0.5
  max_gradient 10
  contained_by {
    sphere{
        <0,0,0>, 3.7
    }
  }
  pigment { color rgbt<0.7,0.7,0.7,0.2> }
  rotate<180,0,0>
  translate<0, 4, 0>
  scale<0.5,0.5,0.5>
}


Post a reply to this message

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