POV-Ray : Newsgroups : povray.text.tutorials : trivial but useful Server Time
15 Oct 2024 06:25:29 EDT (-0400)
  trivial but useful (Message 1 to 1 of 1)  
From:
Subject: trivial but useful
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.