POV-Ray : Newsgroups : povray.general : Function: Problem in Defining : Re: Function: Problem in Defining Server Time
19 Apr 2024 21:38:06 EDT (-0400)
  Re: Function: Problem in Defining  
From: Bald Eagle
Date: 5 Apr 2018 12:35:00
Message: <web.5ac64f683ce80830c437ac910@news.povray.org>
> #declare Number = function(MyNumber)
> {
>  #declare MyAngle = rand(NySeed)*MyNumber;
>  #declare MyPositive = rand(MySeed)*1.0;
>  #if(MyPositive<0.5)
>   MyAngle*(+1) // no #declare and no ;
>  #else
>   MyAngle*(-1) // no #declare and no ;
>  #end
> }
>
> rotate < 0.0, Number(1.2), 0.0 >

What you're doing is not a function, but a macro.

A function operates like this:

#declare PosOrNeg = function (N) {select(N, -1, 1)};
#declare Seed = seed(123);

#for (Num, 1, 10)
 #declare N = rand (Seed)-0.5;
 #debug concat( " Result = ", str(PosOrNeg(N), 3, 1), "\n")
#end

You can then incorporate that into a calculation to give you an angle multiplied
by 1 or -1.


Post a reply to this message

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