POV-Ray : Newsgroups : povray.advanced-users : user-defined functions-- basic question of use : Re: user-defined functions-- basic question of use Server Time
29 Apr 2024 11:34:24 EDT (-0400)
  Re: user-defined functions-- basic question of use  
From: Alain
Date: 25 Feb 2018 19:14:18
Message: <5a93515a@news.povray.org>
Le 18-02-25 à 14:18, Kenneth a écrit :
> I'm familiar with using PIGMENT/PATTERN functions, although it has been awhile.
> But I was looking at 3.3.1.8.4 "Declaring User-Defined Vector Functions" in the
> docs, and it's not clear to me how to actually *use* the examples given there.
> 
> The first example (a transform function) is described only like this:
> 
> #declare foo = function {
>    transform {
>      rotate <90, 0, 0>
>      scale 4
>      }
>    }
> 
> #declare myvector = foo(4, 3, 7);
> 
> How is "myvector" supposed to be used? My assumption is that it 'acts like' a
> transform-- just like any transform{..}-- but I can't get it to work. Maybe I'm
> using it in a totally wrong way? I tried all sorts of permutations in a sphere
> object, but NONE of them work-- all fatal errors. (Some of these are probably
> nonsense, but I wanted to be thorough.) Can someone give an example of the
> correct way to use  myvector-- in a sphere, or in some other way altogether? I'm
> obviously not grasping the underlying idea.
> 

The foo function don't take any paremeter at all.
All function need the parantesis.

So, myvector will always be :
transform{rotate <90,0,0> scale 4}
It shold be named "MyTransform" to have a descriptive name.

The only way that I can think of using that function that should work is :

transform{foo()}

If you apply that to a sphere situated at the origin, the only visible 
effect will be to scale it by 4.

Try :
sphere{<0,1,0> 1 transform{foo()}}


Post a reply to this message

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