mondayBanner // 12 May 2008

_20080512_3dGrid
run the sketch—view the code

How do you use it?
-Move the mouse left and right to spin the cube.
-Move the mouse up and down to zoom in or out.
-Click and shift-click to tilt the cube.
-Space bar saves a .tif of the image. (only in Processing, doesn’t work in browser)

What is it?
A function called grid() uses two nested for() loops to determine the X- and Y-coordinates for a grid of circles. A separate for() loop translates the drawing matrix along the Z-axis and draws a grid each time. The result is a three dimensional matrix of circles.

I originally wanted to do it with spheres, but it seems that 1000 spheres is too much for the processor to keep up with. With only 125 spheres it barely worked. There was no real difference in performance between OpenGL and P3D. I have a hunch that the code could be optimized to handle larger numbers but I’m not sure where to start. Any suggestions? Should I recall the coordinates from an array? Should I go OO? I welcome comments…

Comments are closed.