We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › good way to work with a 3d grid
Page Index Toggle Pages: 1
good way to work with a 3d grid (Read 988 times)
good way to work with a 3d grid
Dec 31st, 2009, 6:28am
 
What is a good way to work with a 3d grid.

On the grid points will be set (probably with triangulation hack
http://processing.org/hacks/hacks:triangulation).

But before it triangelates i need to check certain things.
If a point is surrounded by 6 points for example then it should be deleted (1grid unit away)(one on the left, 1 on the right, one in fron, 1 behind, 1 above and 1 under.
Also each point that has less then 3 points around them should be deleted.

also when gets an array to big?
Cause 64.000.000 is quite big right? Smiley
Re: good way to work with a 3d grid
Reply #1 - Dec 31st, 2009, 6:40am
 
It would be nice if the grid can be usid with a function like:

check(x, y, z);

so it can report if there is a point or not on that position,
Re: good way to work with a 3d grid
Reply #2 - Dec 31st, 2009, 7:11am
 
Sounds like you are trying to do something like Conway's 'Game of Life' in 3D is that correct?

Re: good way to work with a 3d grid
Reply #3 - Dec 31st, 2009, 7:18am
 
maybe an boolean array you can set true or false. and then check ?
Re: good way to work with a 3d grid
Reply #4 - Dec 31st, 2009, 8:08am
 
no quark not that i know, i will post a pic later of what i'm doing.

is 64.000.000 much?

and for credic yeah maybe but i have to navigate so i know what's below etc.
Re: good way to work with a 3d grid
Reply #5 - Dec 31st, 2009, 11:38am
 
I tried the following in Processing
Code:

void setup(){
 size(400,400);
 int d = 400;
 int x[][][]  = new int[d][d][d];
 println("DONE");
}

A 3D array with 64,000,000 integers and each requires 4 bytes - so the array requires 256,000,000 bytes (244.14Mb). Initially Processing refused to create the array but you can increase it in the Preferences option. I set aside 256Mb and it accepted it. If you only need to know it exists the Cedric's boolean array is good since Java requires just 1 byte of RAM per boolean.
Smiley
So it seems possible to create such large arrays but doing the calculations on 64million elements would be time consuming.
This is particularly true with multidimensional arrays for instance the 3D array created above is actually an array of arrays of arrays.
Huh
One possible solution is to use a single dimensional array and calculate the offsets for the dimensions. See thread http://processing.org/discourse/yabb2/num_1262269249.html

Page Index Toggle Pages: 1