POV-Ray : Newsgroups : povray.advanced-users : Either pov or Greg fails at simple addition : Re: Either pov or Greg fails at simple addition Server Time
29 Jul 2024 18:24:18 EDT (-0400)
  Re: Either pov or Greg fails at simple addition  
From: Ron Parker
Date: 26 Feb 2001 09:27:27
Message: <slrn99kpuh.tal.ron.parker@fwi.com>
On Mon, 26 Feb 2001 09:12:37 -0500, Greg M. Johnson wrote:
>"Greg M. Johnson" wrote:
>
>> #macro rdr()
>> (rand(RRR)-0.5)+(rand(RRR)-0.5)+(rand(RRR)-0.5)+(rand(RRR)-0.5)
>> #end
>
>If you replace that macro with this one, the world returns to normal.

I'll bet it doesn't really.

>WHY!?  Is there an error in what povray (note: using mega 0.6) does with
>parens???

It's not an error, but it might be unexpected if you think macros act like
functions.  This line:

#declare brakepct=      0.91+0.05*rdr();

is parsed as

#declare brakepct=0.91+0.05*(rand(RRR)-0.5)+(rand(RRR)-0.5)+(rand(RRR)-0.5)+
(rand(RRR)-0.5);

As you can see, the .05 only applies to the first term of your addition.
Your macro should read

#macro rdr()
((rand(RRR)-0.5)+(rand(RRR)-0.5)+(rand(RRR)-0.5)+(rand(RRR)-0.5))
#end

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

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