Perlin Noise

Another important way to simulate randomness is using Perlin noise generation. Perlin noise generation differs from random generation as it uses a “smooth” sequence of psuedo random numbers, where a singular value in a sequence depends on its predecessors. This is especially useful in creating natural phenomena such as clouds and the textures of materials like marble or wood. Take these examples;

Screen Shot 2014-10-10 at 13.12.13 Screen Shot 2014-10-10 at 13.13.18

This example assigns a random brightness to each pixel on the screen. Notice how dark pixels are adjacent to light ones, creating a grainy texture.

Screen Shot 2014-10-10 at 13.07.44 Screen Shot 2014-10-10 at 13.05.50

However this sketch assigns a random brightness to each pixel on the screen using Perlin noise. As the brightness value of each pixel depends on its neighbours, clumps of brightness and darkness form.

Beginning The Nature Of Code

To carry on from the Processing work we did in class, I began to read the book The Nature of Code and start some of the exercises within it. The aim of the book is to teach the reader how to program how to model a digital “ecosystem” using concepts from biology and physics. I chose to look into this book to learn some more advanced programming skills and hopefully I can complete most of the assignements.

To start off the book talks about normal distribution and how in nature variable information usually lies along a bell curve. For example take people’s heights. The height of people can vary greatly, but if you looked at everyone’s heights as a data set, more people would be near the average height than at the two extremes. The mathematics behind this is called Gaussian distribution.

The equations for this are included in the Java library and a version of this is included in Processing. Take for example this code which uses Gaussian distribution to place white dots around a particular point.

gaussiancode gaussian

The lines generator.nextGaussian() creates a Gaussian distribution with ysd and xsd being the standard deviation and xmean and ymean being the mean. The circles are semi transparent so one can see the brighter areas near the middle where more of the dots are clustered, whereas on the outside the dots are more faint as they are less likely to be placed there.

Shiffman, D., 2012. The Nature of Code [online] Mountain View: Creative Commons.

Learning how to use Arduino

Our course recently ordered some new hardware for us to learnĀ  and play around with. One of these is the Arduino, an open source platform used for prototyping electronics.

The only experince I have had with electronics is during high school physics lessons and they were mainly simple circuits, so I thought it would be useful to learn a bit more about this for future projects. To begin learning how to use the Arduino I followed a tutorial on making an LED light first blink, then blink faster when a button is pressed.

Here is the code I used:

Arduino1

The arduino uses inputs and output ports. This code sets the LED to an output and the button as an input. A loop cycle is created where power is sent to the LED, the loop is delayed for a period of time (leaving the light on), then no power is sent to the LED (turning the light off). If the button is pressed the time of the delay is shorter, making the blinking faster.

Here is a video.

I then tried out my own extention of this code. It’s very simple but it helped me to understand and cement the basics, especially of the concepts of ports, in my mind. This time the LED I attached to the breadboard lights up when the button is pressed and turns off when it is not pressed.

Here’s the code:

Arduino2

And here’s the video:

Here’s a link to the website of the Arduino Project.

http://arduino.cc/