Re-Code

Introduction

Schleifen Als Schleife wird das wiederholte Ausführen von Anweisungen bezeichnet. Auf diese Weise können die Anweisungen definiert, modifiziert oder einfach nur ein vielfaches durchgeführt werden bevor eine Abbruchsbedingung eintrifft. In Processing gibt es drei Möglichkeiten für Schleifen: while, do... while und for. Der Syntax der for-Schleife lautet:

for (Anfangsbedingung, Abbruchbedingung, Veränderung der Anfangsbedingung)
{
/*Schleife wird solange ausgeführt, bis die Abbruchsbedingung eintritt*/
}

Exercises

Calculation

Your browser does not support the canvas tag.

Get the Code: mapping.pde

Your browser does not support the canvas tag.

Get the Code: distance.pde

Loops

Your browser does not support the canvas tag.

Get the Code: forLoop.pde

Your browser does not support the canvas tag.

Get the Code: whileLoop.pde

Grids width Loop

Your browser does not support the canvas tag.

Get the Code: forLoopGrid.pde

Your browser does not support the canvas tag.

Get the Code: whileLoopGrid.pde

Noise

EinTeil der allgemeinen Lektion der Natur ist das Verständnis, wie Ordnung und Chaos zueinander in Beziehung stehen. [ Alan Powers, Natur und Design. S. 33. ]

Rauschen Rauschen beschreibt in der Physik eine Störgröße, welche durch die Überlagerung von Schwingungen oder Wellen entsteht. Geläufige visuelle Beispiele sind u.A. das Bildrauschen bei hohen ISO-Werten in der Fotografie und der »Ameisenkrieg« bei fehlendem Senderempfang im Fernsehen. Dieses Phänomen kann über ein mathematisches Modell beschrieben werden, genannt »Weißes Rauschen«.

Perlin Noise Noise ist eine fraktale Rauschfunktion. Sie wird zur Bildsynthese natürlicher Phänomene, wie Wolken, Landschaften und Wasser, verwendet. Ken Perlin, nachdem diese Funktion benannt wurde, hat Perlin Noise entwickelt um Sachen, z.B. Bilder und Oberflächen, unregelmäßig genug aussehen zu lassen, wodurch diese interessanter und natürlicher erscheinen. Die Funktion selbst macht nicht viel anderes, als ein einfaches, sich nicht wiederholendes Muster zu generieren. Noise gehört nicht zu den Zufallsfunktionen, Noise ist pseudozufällig.

Your browser does not support the canvas tag.

Get the Code: noiseVSrandom.pde

Comparision of random() (top) and one-dimensionalnoise(). Plus button for next. Minus for previous.

Noisy Plates

Source http://dianalange.tumblr.com/post/72549366477/dr-mitch-noisy-plates-generated-with
by Michael Roderfeld (Website, tumblr).

Your browser does not support the canvas tag.

Get the Code: rotateTranslate.pde

Plus and minus change angle.

Your browser does not support the canvas tag.

Get the Code: plates.pde

One dimensional noise using vertex-shape.

Your browser does not support the canvas tag.

Get the Code: plates_2.pde

Adding a loop for more noise lines. Rotating the matrix around a random angle.

Task

Your browser does not support the canvas tag.

1. Add some random values and variabes so it looks different every time!
2. Add a control which will create a new Noise Plate every time you call it(keyPressed or mousePressed)

Gaussian distribution

A distribution of values that cluster around an average (referred to as the “mean”) is known as a “normal” distribution. It is also called the Gaussian distribution (named for mathematician Carl Friedrich Gauss) or, if you are French, the Laplacian distribution (named for Pierre-Simon Laplace). [ Daniel Shiffmann: Nature of Code. http://natureofcode.com/book/introduction/ ]

Your browser does not support the canvas tag.

Get the Code: randomGaussRandom.pde

Click to start over. Comparison of Gaussian distribution (top) and e random (min, max); distribut (bottom).

The random (); generated numbers create an uniform pattern. The Gauss distribution shows a surrounding around the mean value (center of window).

import java.util.*; /*Importing the Java library which provides the Random class*/
Random generator; /*Defining a new instance of Random*/
float sd = 100; /* Standard Deviation*/
float mean = 300; /* average */

void setup()
{
   size(600, 200);
   generator = new Random();
   background(#7a9686);
}

void draw()
{
   float num = (float) generator.nextGaussian(); /* returns a normal distribution of random numbers with a mean of zero and a standard deviation of one*/
   float x = sd * num + mean; /* our target mean ain't zero so we add our mean value, the target standart deviation isnt't 1 so we muliply it with our value */ fill (255, 5);
   ellipse(x, 50, 20, 20);
}

Monochromatic Resonator

Source http://tsrono.tumblr.com/post/72156042845
by Jeffrey Simmons (Website, tumblr).

Short References

Gaussian distribution import java.util.*;
Random generator = new Random();
float num = (float) generator.nextGaussian();

For Loops for (Starting condition; stop condition; change of start condition)
{
/* Content */
}

while Loops while (condition)
{
/* while the condition is true this part will loop */
}

Matrix pushMastrix (); /*saves current status of the coordination system*/
popMatrix (); /*restores status of matrix*/
translate (x, y); /*translates the coordination system */
rotate (angle); /*rotates the coordination system */

Angles PI /*System varible*/
TWO_PI/*System varible*/
sin (angle);
/*Angle should be in radians 0 > TWO_PI */ cos (angle);
float degreesToRadians = radians (angle); /*Convertes angle (in degrees) to radians */

Calculation map (value, start1, stop1, start2, stop2); /*Re-maps a number from one range (start1, stop1) to another (start2, stop2)*/
constrain (value, low, high); /* Constrains a value to not exceed a maximum and minimum value*/
dist (x1, y1, x2, y2); /*calulates the distance between two points*/