POV-Ray : Newsgroups : povray.newusers : User-defined vector functions : Re: User-defined vector functions Server Time
28 Jul 2024 20:28:43 EDT (-0400)
  Re: User-defined vector functions  
From: Tim Attwood
Date: 8 Oct 2008 19:04:40
Message: <48ed3c88$1@news.povray.org>
>> I find myself making sets of user-defined float functions because I can't 
>> figure
>> out how to make a user-defined vector function.  I end up with stuff like 
>> this:
>>
>> #declare LocX = function(x) { x + 1 }
>> #declare LocY = function(y) { y * 2 }
>> #declare LocZ = function(z) { z / 3 }
>>
>> I'd *much* rather have this:
>>
>> #declare LocXYZ = function(x, y, z) { <x + 1, y * 2, z / 3> }
>>
>> Any chance there's an easy way to do this?  Will I have to use a macro?
>
> A macro is best suited for this:
>
> #macro LocXYZ (x0,y0,z0)
>  #local x1=x0+1;
>  #local y1=y0*2;
>  #local z1=z0/3;
>  <x1,y1,z1>
> #end
>
> evaluate using:
>
> #declare A=LocXYZ(1,2,3);
>
You can represent simple linear equations as transforms...

#declare LocXYZ = function {
   transform {
      scale <1,2,1/3>
      translate <1,0,0>
   }
};

For more complex equations you are stuck using macros, splines, or pigments.


Post a reply to this message

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