POV-Ray : Newsgroups : povray.general : Array and vector functions? : Re: Array and vector functions? Server Time
6 Oct 2025 21:42:28 EDT (-0400)
  Re: Array and vector functions?  
From: Bald Eagle
Date: 3 Oct 2025 15:50:00
Message: <web.68e02838c4b39641e2c47eda25979125@news.povray.org>
Ilya Razmanov <ily### [at] gmailcom> wrote:
> Greetings sentients,
>
> do I understand it correctly that POV-Ray does not have array functions
> (meaning I can neither pass an array as argument nor receive it as a
> result), and vector functions are so limited that practically aren't
> worth mentioning?

You are correct in that they do not exist as inbuilt functions

The best we have is

https://wiki.povray.org/content/Reference:Function

Declaring User-Defined Vector Functions
Right now you may only declare vector functions using one of the special
function types. Supported types are transform and spline functions.

For example:

#declare foo = function {
  transform {
    rotate <90, 0, 0>
    scale 4
    }
  }

#declare myvector = foo(4, 3, 7);

#declare foo2 = function {
  spline {
    linear_spline
    0.0, <0,0,0>
    0.5, <1,0,0>
    1.0, <0,0,0>
    }
  }

#declare myvector2 = foo2(0.7);
Function transforms return a three component vector, while function splines take
the vector size into account. That is, a function containing a spline with five
components will also return a five component vector (aka a color), a function
containing a spline with two components will only return a two component vector
and so on.

Note: The number of parameters of special function types is determined
automatically, so you do not need to specify parameter names.

Depending on what you want to specifically do, there might possibly be a
workaround.

- BE


Post a reply to this message

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