We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi
I create a class GRID which has two 3d arrays, made of many layers of 2d arrays. I need to declare and initialise the object in the constructor to then access it from other build-in functions. So I create the layers I need (int[][]), and lately declare the double[][][] my_3d_array = {layer1, layer2, layer3, ....}. All of this happens in the constructor.
However, if I do not declare the 3d array within the constructor, processing protests and says that the form {var1, var2,...} can be done if those vars are constant.
Whatever way I walk through, a later on defined built-in function of the class do not recognise this array3d, and it sees it as null.
Any ideas how to tackle this?
Thank you
Answers
You need to put this another way :
double[][][] my_3d_array = {layer1, layer2, layer3, ....}
e.g.
a for loop for the layers (z)
Then a nested for-loop for the single layer (x,y)
then assign the value like 3darray[x][y][z]=layer[x][y];
But which layer ?
His Chrisir
Thank you for your reply.
This has just been my early-morning-eureka and it will work for my case since I have just 8 layers. Otherwise, how would you automatically run the for loop calling a different variable (layer) for each cycle of it?
Best
Try
my_3d_array = new double[][][]{layer1, layer2 ...};
, initialising it beforehand.https://forum.Processing.org/two/discussions/tagged/3darray
Thank you both guys. Tried your method Lord_of_the_Galaxy, it works.
I'm still quite new to processing, that is the main issue.