POV-Ray : Newsgroups : povray.programming : "circular" arrays : "circular" arrays Server Time
24 Feb 2024 17:00:03 EST (-0500)
  "circular" arrays  
From: Bald Eagle
Date: 20 Oct 2019 15:40:07
Message: <web.5dacb781225c97d94eec112d0@news.povray.org>
So, I was working on a bit of code, it was late, and I thought perhaps that
mod() would take a negative number and wrap it around to the "top", but it of
course does not.  Then I got a "negative subscript" error when trying to address
an array element.

I was wondering if it might be sufficiently helpful so as to warrant an array
type that would automatically wrap in either direction - perhaps with a warning
that could be disabled.

So an array with 5 elements (#declare array = array [5]) would yield Array[0] if
Array[5] were addressed.   And likewise Array[-1] would yield Array [4].

Something like carray for "cyclic array" or marray for "modulo array"...

Perhaps a spiral array would find use in navigating data as well - a 2
dimensional array where overrun in either direction in one dimension would shift
over to the edge element in the next dimension.

Post a reply to this message

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