POV-Ray : Newsgroups : povray.general : Fuctions, My two cents : Fuctions, My two cents Server Time
24 Apr 2024 00:44:00 EDT (-0400)
  Fuctions, My two cents  
From: Leroy
Date: 24 Feb 2023 20:25:00
Message: <web.63f9632653db63fbba5ca48bf712fc00@news.povray.org>
While playing with functions came upon this:
 you can create a macro that outputs a function with other #local functions
supporting that function and you call that macro several times for different
outputs.

Like this example:

#macro Gf_waves(r,c,d,V)
  #local g=radians(r);
  #local h=V*<1,1,1>+<.5,0,.5>;
  #local q=<c,1,d>;
  #local PigFa= function {pigment {waves color_map{[0,rgb 0][1,rgb 1]} scale q
        rotate y*r translate h}};
  #local PigF0= function {1-PigFa(x,0,z).hf}
  function(x,z){PigF0(x,0,z)}

#end

Used like this:

#declare Small_Waves=Gf_waves(0,1,1,0)
#declare Mid_Waves=Gf_waves(0,2,2,0)
#declare Big_Waves=Gf_waves(0,9,9,0)

The neat part is that you can used the #local function names in another macros
without conflict.

and you can combine functions like this

#declare Ground=function(x,z){Mat(x,z)*Dirt(x,z)}

I use version 3.7 haven't try it on any of the other versions.


Post a reply to this message

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