POV-Ray : Newsgroups : povray.general : <no subject> : Re: <no subject> Server Time
29 Jul 2024 04:16:39 EDT (-0400)
  Re: <no subject>  
From: Kenneth
Date: 15 Jan 2013 23:25:01
Message: <web.50f62b4e6f92e856c2d977c20@news.povray.org>
Besides Cousin's Ricky's suggestion, there are some other coding flaws (some of
which I'm still trying to work through, to figure out what's going on.) I had to
refer to section 3.2.1.8.2  "Array Initializers" in the documentation to brush
up on array usage. But I can offer *some* help.

It's probably best to examine your code part-by-part. Here's the first problem I
see:

#declare MyTable = array[3][6] {{0,0,0,0,0,0},{0,0,0,0,0,0},{0,0,0,0,0,0}}

There are multiple issues here.
1) The 2nd part of a two-dimensional array...[6] in your case... isn't meant to
specify the number of values in each of the three separate inner 'elements.'
I.e., not six values like in <0,0,0,0,0,0>. But rather, it specifies the number
of 'elements' going horizontally (or columns as the documentation says.) That
should be six elements here, not just the three that you have. And your [3)
specifies the number of rows. (If that code line didn't have additional
problems, your way of specifying it would work OK, regarding how to quickly
initialize an array. But read on...)

2) It looks like you're trying to (or wish to) specify a *vector* for each of
the elements--but there are no <....> vector symbols. Instead, you've
substituted curly brackets for them. OR, perhaps you've misunderstood the
example given in the docs. Here is its single-dimensional example:

#include "colors.inc"
#declare FlagColors = array[3] {Red,White,Blue}

The Red etc. values are actually vectors, like <1,0,0> (or maybe <1,0,0,0,0>)

BTW, there's a subtle difference in syntax between specifying a
single-dimensional array and a multi-dimensional one, having to do with how many
curly brackets to use. A one-dimensional array uses only one set; a
multi-dimensional array uses two (or more? I'm not sure about that myself.)

3) An array 'element' can hold only five values at most. You've used
six...<0,0,0,0,0,0>

4) Initializing a *multi*-dimensional array with values/elements is more complex
than shown in the one-dimensional array example. More elements need to be
specified, unfortunately. (Perhaps there's a shorthand way of doing so, but I
don't know.)

So here's your chunk of code rewritten, which works OK (that is, by itself!)
Three rows, with six 'elements' each, and only five values in each element:

#declare MyTable = array[3][6]
{
{<0,0,0,0,0>,<0,0,0,0,0>,<0,0,0,0,0><0,0,0,0,0>,<0,0,0,0,0>,<0,0,0,0,0>}
{<0,0,0,0,0>,<0,0,0,0,0>,<0,0,0,0,0><0,0,0,0,0>,<0,0,0,0,0>,<0,0,0,0,0>}
{<0,0,0,0,0>,<0,0,0,0,0>,<0,0,0,0,0><0,0,0,0,0>,<0,0,0,0,0>,<0,0,0,0,0>}
}

This doesn't solve your whole problem, though; there's still something wrong
somewhere, in the #while loop (OR in your example's use of it, not sure which.)


Post a reply to this message

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