# Needing help with a design

Hi,

I’m trying to create a 3D grid, like the pic below:

But I’d also like to add circles onto each axis: X, Y, Z. I’d appreciate any help. I have more than half of it done.
Here’s the code I have so far:

``````int gridSize = 10;
float inc = 0.001;
int density = 10;
float znoise = 0.0;

void setup() {
size(800,800,P3D);
background(0);
smooth();
noFill();
stroke(255);
}

void draw(){
background(0);
pushMatrix();
translate(width/2, height/2);
for(int i = -width/2; i < width/2; i+=gridSize) {
for(int j = -height/2; j < height/2; j+=gridSize) {
int y = 200;
line(i, y, j, i+gridSize, y, j);
line(i, y, j, i, y, j+gridSize);
}
}
popMatrix();
float xnoise = 0.0;
float ynoise = 0.0;
for (int y = 0; y < 600; y += density) {
for (int x = 0; x < width; x += density) {
float n = noise(xnoise, ynoise, znoise) * 160;
fill(100, n, 100);
rect(x, y, density, density);
xnoise += inc;
}
xnoise = 0;
ynoise += inc;
}
znoise += inc;
}
``````

Make sure you format your code using the </> button!

Drawing the circle on the xy plane shouldn’t be too difficult, but as for the other 2 planes, try rotating and translating to get the ellipse where you want it to be, and then draw the circle using the ellipse() function (making sure all of this is within push/popMatrix).

1 Like

Would it be possible to show an example in the code? I’d appreciate it.

I wrote some code for 2 of the ellipses, the ones on the x-y plane and on the x-z plane.
I have left the last one to you.
(There doesn’t seem to be a y-z plane on the left or right of the screen to draw the last ellipse on though.)

``````[...]
draw(){
[...]
fill(255); //Color of ellipses
ellipse(width/2, height/2, 50, 50); //xy
pushMatrix();
translate(0, 3*height/4, 0);
rotateX(TAU/4);
ellipse(width/2, height/4, 50, 50); //xz
popMatrix();
//Code for last ellipse goes here
}
``````