POV-Ray : Newsgroups : povray.general : Macro problem : Re: Macro problem Server Time
29 Jul 2024 00:37:27 EDT (-0400)
  Re: Macro problem  
From: MichaelJF
Date: 11 Oct 2013 06:15:01
Message: <web.5257ce9030eb22c6e83c0f490@news.povray.org>
"posfan12" <nomail@nomail> wrote:
> I'm using RC7 by the way.
>
>
> "posfan12" <nomail@nomail> wrote:
> > I'm trying to write a macro that randomly either returns -1 or 1. This is what I
> > have:
> >
> > #macro randsign()
> >  #if (rand(HPlanet_Seed_Value) > 0.5)
> >   1
> >  #else
> >   -1
> >  #end
> > #end
> >
> > However, POVray stops rendering and says "All #declares of float, vector, and
> >  color require semi-colon ';' at end if the language version is set to 3.5 or
> >  higher."
> >
> > What am I doing wrong? Adding the semi-colon causes the scene to quit for other
> > reasons.

Better thsi one:

#declare Zufall=seed(317);

#macro randsign()
   #local Z1=rand(Zufall)-0.5;
   #if (Z1=0) Z1=0.1; #end     // avoid division by zero
   Z1/abs(Z1)
#end

#declare Count=0;
#while(Count<100)
   #declare ZufallsZahl=randsign();
   #debug concat("Zufallszahl: ",str(ZufallsZahl,8,4),"\n")
   #declare Count=Count+1;
#end


Post a reply to this message

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