POV-Ray : Newsgroups : povray.general : Parameters to functions used in expressions ... : Re: Parameters to functions used in expressions ... Server Time
2 Aug 2024 04:20:38 EDT (-0400)
  Re: Parameters to functions used in expressions ...  
From: Slime
Date: 19 Jan 2005 09:09:22
Message: <41ee6a12$1@news.povray.org>
> Do arrays work in the same way ? I recall having tried to get a value in
> an array, indexed by a parameter of a function (something like
> function(x) {myarray[floor(x)]} ) and never being able to find a way to
> do so...

Yes; since array elements are evaluated during parse time, the index of the
array can't be dependant on function arguments which would only be available
when the function is evaluated. The number within the [] brackets must be
something that can be evaluated ahead of time, and then the function will be
equivalent to function(x) {3} or something like that.

(There are ways, however, to construct a function from an SDL array that
will work essentially like a lookup on the array. Unfortunately, the lookup
will be at best an O(log(n)) search instead of an O(1) lookup, and the
function will take more memory than the original array itself.)

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

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