POV-Ray : Newsgroups : povray.text.tutorials : Summing over indices of an array : Re: Summing over indices of an array Server Time
2 Mar 2024 12:26:29 EST (-0500)
  Re: Summing over indices of an array  
From: nomail
Date: 3 Jan 2006 00:45:00
Message: <web.43ba0e404b456960963fc0330@news.povray.org>
"moocow" <nomail@nomail> wrote:
> What if I want to define a function as a sum of other functions?

There is nothing preventing you from doing it.

> #declare X = array[N]
> //set X's
> #declare f = function{ sum(i, 0, N-1, pow(.5, pow( vlength(<x,y,z> - X[i]),
> 2))) }
> I can't think of how to make that work.


> Also, why these restrictions?

Why is the sky blue? The primary use for functions is in isosurfaces,
functions are not a macro replacement.

> Why can't I sum outside a function or

The SDL supports means to compute the sum via a macro.

> use arrays inside?

Arrays exist while parsing, functions are evaluated while rendering.
Functions are not macros!

> Why can't I do:
> #define f1 = function { f1(x,y,z) + g(x,y,z) }
> ?

This cannot work as it creates an infinite recursion!

Post a reply to this message

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