Coding, Geometry Joys, Java, Murderous Maths

2D and 3D Transformations in Processing (Java) Continued

Simon continued his lectures about transformations in Processing (Java). Processing has built-in functions that make it easy for you to have objects in a sketch move, spin, and grow or shrink: the translate, rotate, and scale functions. Simon has already covered the translate and rotate functions in an earlier post. Today he made tutorials about scaling and 3D transformation functions pushMatrix() and popMatrix().

Scaling changes the size of the grid:

 

And here come the pushMatrix and the popMatrix functions:

The explanation below comes from the Processing website:

The Transformation Matrix

Every time you do a rotation, translation, or scaling, the information required to do the transformation is accumulated into a table of numbers. This table, or matrix has only a few rows and columns, yet, through the miracle of mathematics, it contains all the information needed to do any series of transformations. And that’s why the pushMatrix() and popMatrix() have that word in their name.

Push and Pop

What about the push and pop part of the names? These come from a computer concept known as a stack, which works like a spring-loaded tray dispenser in a cafeteria. When someone returns a tray to the stack, its weight pushes the platform down. When someone needs a tray, he takes it from the top of the stack, and the remaining trays pop up a little bit.

In a similar manner, pushMatrix() puts the current status of the coordinate system at the top of a memory area, and popMatrix() pulls that status back out. The preceding example used pushMatrix() and popMatrix() to make sure that the coordinate system was “clean” before each part of the drawing. In all of the other examples, the calls to those two functions weren’t really necessary, but it doesn’t hurt anything to save and restore the grid status.

Note: in Processing, the coordinate system is restored to its original state (origin at the upper left of the window, no rotation, and no scaling) every time that the draw() function is executed.

Coding, Geometry Joys, Java, Murderous Maths

3D Earthquake Data Visualization Coding Challenge

The earthquake data visualization coding challenge by Daniel Shiffman went further than just a 2D map – it went 3D! Simon managed to complete the challenge, except for the very last bit where he was supposed to correct the skewed GPS positions of the earthquake locations on his own (this part was not included in the challenge).

 

 

 

 

 

Coding, Geometry Joys, Milestones, Murderous Maths

Crazy Supershapes

 

We have purchased something Simon wanted to have for months already: new software to construct the craziest 3D-supershapes! The software is pretty old, developed by Australian programmer Paul Bourke long before Simon was even born. Paul Bourke turned out to be a real person, alive and well – he promptly replied to our e-mail after we had trouble downloading our purchase.

All of the supershapes are built by entering certain values in one formula:

schermafbeelding-2017-01-17-om-01-56-16

 

img_3199