This is the fifth example of the ‘Formulated bodies’ chapter. The Generative Design book describes this example as follows: ‘Generally speaking, all three-dimensional forms defined by mathematical functions can be generated with the last version of the previous program. Since rendering with complicated functions or a very large number of grid points can be very CPU-intensive, a simple optimization of the code should be performed. At the moment, all the grid points are newly calculated for each frame (i.e., each time the grid is drawn). It would suffice, however, to calculate the x-, y-, and z-coördinates just once at the beginning. In addition, almost all points are calculated twice: the lower points of a tile row correspond in the end to upper tiles of the next row. It is therefore better to calculate the points at the beginning and to store them in a two-dimensional array..’ Here is the original code from the Generative Design book:
I have prepared a Flickr Album which contains all the images I have made during this assignment. You can find that clicking this url:
Because this assignment is about optimizing code I will still try to make different shapes. Maybe I will repeat myself doing that. I started with adding the arrow down / up with: Zoom – / +. And I imported my light settings from the previous examples. Also changed the global variable names. I also closed the object which was open in the example. It’s now only open at the sides of the object. I definitely do need a screendump function. Used the s-key for that.
Used that single object to make a pattern with two for loops which I also used in the other assignments. And I used some of the functionality which was in the previous sketch series (M.3.2.4). I adjusted the H- & V-MinMaxValue Range during the initialization at the top the program. And I picked up my last bending possibility from M.3.2.4. using rotateX for a minimal bending of the total object.
Increased the amount of objects to a matrix of 32 x 32 objects.
Increased the amount of objects to 64 x 64. And I had to decrease the H & V GridDefinition to 10. Otherwise the sketch would react very lazy.
These are two equal objects. Except one of them is rotated an extra 90 degrees. 90 Degrees gave me better results than rotating it 180 degrees. This is now a matrix of 256 x 256 objects.
Decreased the H & V GridDefinition to 4. But I think at this moment the object gives me too much noise and moiré effects. This can be nice sometimes but it is not in this case.
Still a bit noisy but it’s getting better. Especially when you get up closer to the object. Decreased the H & V GridDefinition to 2. At this point you could ask yourself why still use objects. And that is a very relevant question which I cannot answer. Sometimes you arrive at points which are not really based on logic. But just by doing things step by step you accept that you have arrived at that moment in the process . Hopefully that makes sense. But I agree that this would work with ellipses or rectangles. Because the objects are now of such a size that it is almost only 1 pixel.
In this example I used a matrix of 512 x 512 objects. That makes a total of 262.144 objects. Both rotated by rotateX. But one of them is rotated 90 degrees extra.
In fact this is exactly the same sketch as the previous one. The only difference is that in the for loop (on line 122) j += 2 and on line 123 i++. Everything is copied and an extra rotation of 90 degrees is added. Than I replaced the vertices by the 3D Primitive box. Using 262.144 boxes is of course slowing down my machine. Fortunately I am not in a hurry. But I will half the amount of boxes. That seems not to be enough so I halved the amount again to a matrix of 64 x 64. Which is still 4096 boxes.
This is the same object as the previous sketch. I only modified the for loops.