|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I tracked down my old thread, but no help.
http://news.povray.org/povray.advanced-users/thread/%3Cweb.58e6aa331b66056880403a200%40news.povray.org%3E/
I have a 2D array, and I want to have that array be a collection of other 2D
arrays.
Is that allowed?
How do I access, or more importantly assign, uninitialized "internal" 2D array
elements?
#declare Array1 = array [4][4];
#declare Array2 = array [4][4];
Partially fill Array 2 with some values.
#declare Array1 [2][3] = Array2;
So far so good - but now I need to get to the "array formerly known as Array2 ",
element [0][2] which is INSIDE of Array1 [2][3]
#declare Array1[2][3][0][2] = somevalue makes the POV-Ray parser cry.
I'm none to happy about it either.
Advice? Solution(s)?
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
hi,
"Bald Eagle" <cre### [at] netscapenet> wrote:
>
> #declare Array1 = array [4][4];
>
> #declare Array2 = array [4][4];
>
> Partially fill Array 2 with some values.
>
> #declare Array1 [2][3] = Array2;
>
> So far so good - but now I need to get to the "array formerly known as Array2 ",
> element [0][2] which is INSIDE of Array1 [2][3]
>
> #declare Array1[2][3][0][2] = somevalue makes the POV-Ray parser cry.
>
> I'm none to happy about it either.
>
> Advice? Solution(s)?
assign Array1[2][3] to a variable, then access that like the array. given the
above and the four elements of Array2[1][?] set to some value, the following
works for me:
#declare TA = Array1[2][3];
#debug concat("TA 1 2", str(TA[1][2], 0, 0), "\n")
hth.
regards, jr.
Post a reply to this message
|
|
| |
| |
|
|
From: clipka
Subject: Re: Directly accessing array value in array of arrays (Part 2)
Date: 27 Aug 2018 05:56:48
Message: <5b83cae0$1@news.povray.org>
|
|
|
| |
| |
|
|
Am 27.08.2018 um 01:22 schrieb Bald Eagle:
> I tracked down my old thread, but no help.
>
>
http://news.povray.org/povray.advanced-users/thread/%3Cweb.58e6aa331b66056880403a200%40news.povray.org%3E/
>
> I have a 2D array, and I want to have that array be a collection of other 2D
> arrays.
>
> Is that allowed?
Yes, absolutely - although I've heard rumors that /someone/ just
discovered a bug that may cause a crash instead of a parse error if
arrays of arrays are used and mistakes are made ;)
> How do I access, or more importantly assign, uninitialized "internal" 2D array
> elements?
>
> #declare Array1 = array [4][4];
>
> #declare Array2 = array [4][4];
>
> Partially fill Array 2 with some values.
>
> #declare Array1 [2][3] = Array2;
Perfectly fine there.
As a side note, it might be worth mentioning that `Array1[2][3]` now
holds a /copy/ of `Array2`, not a reference.
> So far so good - but now I need to get to the "array formerly known as Array2 ",
> element [0][2] which is INSIDE of Array1 [2][3]
>
> #declare Array1[2][3][0][2] = somevalue makes the POV-Ray parser cry.
I doubt that's what you're actually seeing, because that exact construct
works perfectly fine here.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
hi,
clipka <ano### [at] anonymousorg> wrote:
> As a side note, it might be worth mentioning that `Array1[2][3]` now
> holds a /copy/ of `Array2`, not a reference.
prompted me to (quick) try arrays with different dimensions contained in Array1
and found I can access all values directly through Array1, irrespective of the
number of dims. neat + convenient. thank you.
regards, jr.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"jr" <cre### [at] gmailcom> wrote:
> clipka <ano### [at] anonymousorg> wrote:
> > As a side note, it might be worth mentioning that `Array1[2][3]` now
> > holds a /copy/ of `Array2`, not a reference.
I love that this works too:
<----- snip ----->
#version 3.8;
global_settings {assumed_gamma 1}
#declare Aa = array[1][1][1][1][2];
#declare Ab = array[2][2][2][2][2];
#declare Ab[0][0][0][0][1] = 255;
#declare Aa[0][0][0][0][1] = Ab;
#debug concat("0 0 0 0 1 - 0 0 0 0 1 : ",
str(Aa[0][0][0][0][1][0][0][0][0][1],0,0),
".\n")
<----- snip ----->
very neat. :-)
Post a reply to this message
|
|
| |
| |
|
|
From: clipka
Subject: Re: Directly accessing array value in array of arrays (Part 2)
Date: 27 Aug 2018 09:42:38
Message: <5b83ffce$1@news.povray.org>
|
|
|
| |
| |
|
|
Am 27.08.2018 um 13:22 schrieb jr:
> "jr" <cre### [at] gmailcom> wrote:
>> clipka <ano### [at] anonymousorg> wrote:
>>> As a side note, it might be worth mentioning that `Array1[2][3]` now
>>> holds a /copy/ of `Array2`, not a reference.
>
> I love that this works too:
>
> <----- snip ----->
> #version 3.8;
>
> global_settings {assumed_gamma 1}
>
> #declare Aa = array[1][1][1][1][2];
>
> #declare Ab = array[2][2][2][2][2];
> #declare Ab[0][0][0][0][1] = 255;
>
> #declare Aa[0][0][0][0][1] = Ab;
>
> #debug concat("0 0 0 0 1 - 0 0 0 0 1 : ",
> str(Aa[0][0][0][0][1][0][0][0][0][1],0,0),
> ".\n")
> <----- snip ----->
>
> very neat. :-)
I /think/ you're overdoing it a bit ;)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |