POV-Ray : Newsgroups : povray.general : trouble using rand inside of sine function : Re: trouble using rand inside of sine function Server Time
30 Jul 2024 14:16:26 EDT (-0400)
  Re: trouble using rand inside of sine function  
From: Chris B
Date: 4 Dec 2008 17:39:04
Message: <49385c08@news.povray.org>
"Mike" <win### [at] hotmailcom> wrote in message 
news:web.4938266b4d71081ac9b9f9f00@news.povray.org...
> Hi.
> I am trying to create a random phase within a sine function, but keep 
> getting an
> error that a 'function identifier' is expected and I do not understand 
> why.
>
> I am doing:
> #declare R1=seed(1153);
> #declare xspectrum =function{ sin  ( x+  rand(R1)   )    }
>

Hi Mike,

The help says it's not supported.

It's not one of the FLOAT_FUNCTIONS listed in the 'user defined functions' 
section in the help.
Indeed the help specifies that only float functions that apply to float 
values may be used, which excludes rand because it takes an Integer value 
pointing to the predefined seed stream. Below the list of supported 
functions in my copy of the help 'rand' is specifically used as an example 
of functions that are not supported.

I think the reason for the constraint could be associated with the fact that 
functions are able to be interpreted at render-time (rather than just during 
the parse sequence). Someone may be able to give a more comprehensive 
description (I'm at the limit of my understanding here).

Hate to be the bearer of bad news :-)

Regards,
Chris B.


Post a reply to this message

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