POV-Ray : Newsgroups : povray.text.tutorials : trivial but useful Server Time: 26 Jan 2020 10:49:45 GMT
  trivial but useful (Message 1 to 1 of 1)  
From: W³odzimierz ABX Skiba
Subject: trivial but useful
Date: 5 Feb 2002 11: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-2008 Persistence of Vision Raytracer Pty. Ltd.