POV-Ray : Newsgroups : povray.text.tutorials : trivial but useful : trivial but useful Server Time
18 Apr 2024 18:48:49 EDT (-0400)
  trivial but useful  
From:
Date: 5 Feb 2002 06:44:58
Message: <p4hv5ugh4prqd2s2fr7nu0o9vabih5k741@4ax.com>
(for 3.5)

Just two simple and trivial functions but added to math.inc are very usefull
(and probably faster in parsing and executing then whole expression or macro):

#local even=function(N){select(int(N/2)-N/2,0,1,0)};
#local odd=function(N){even(N+1)};

and small example to test it:

#macro Test(T)
  #local S=str(T,0,(int(T)=T?0:-1));
  #if(even(T))
    #debug concat( S , " is even.\n")
  #end
  #if(!even(T))
    #debug concat( S , " isn't even.\n")
  #end
  #if(odd(T))
    #debug concat( S , " is odd.\n")
  #end
  #if(!odd(T))
    #debug concat( S , " isn't odd.\n")
  #end
#end

Test(1)
Test(1.5)
Test(2)

ABX


Post a reply to this message

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