NATURAL SYSTEM STUDIO SHERMAN LAM
CONTENTS
PREFACE
The fluttering of a butterfly's wing in Rio de Janeiro, amplified by atmospheric currents, could cause a tornado in Texas two weeks later. Edward Lorenz We live in a complex world in which everything is interrelated. A flap of a butterfly may cause a chain of irreversible effects on not just the surroundings but the entire world. This is the theory of butterfly effect, coined by Edward Lorenz. From the complex system, it leads to 'Emergence', the resultant of the interactions amongst individual entity in the system. How could one understand or find order in this complex system and how will it influence architectural design? This book will be divided into 3 parts. The first part will look into the theory of emergence with regard to the natural world and architecture. The second part will explore the potential of computational simulation and its technique. The third part document the emergent project developed using the theory of part 1 and the technique in part 2 and hence explore its potential in architecture. Background: http://natgeotv.com/asia/great-migrations/galleries/ A flock of Monarh Butterflies during their seasonal migration.
1.0 THE THEORY OF EMERGENCE
//1.1 Natural Selection and Mutation //1.2 The Complex System //1.3 Architecture //1.4 The Potential Background: http://science.nationalgeographic.com/wallpaper/science/ photos/rocks/giants-causeway/ The Giant's Causeway in Northern Ireland is an example of a complex emergent structure created by natural processes
1.1
It is not the strongest of the species that survives, nor the most intelligent, but the one most responsive to change. Charles Darwin1 The Nature is a complex system which is constantly evolving. It does not follow a top-down approach, and has no predetermined goals. Evolution as suggested by Darwin, is a process of how organisms adapt to its surrounding environment. The new generation is different from the previous generation and it is constantly evolving to adapt to the new environment with mutation as the resultant of the adaptation process. Through natural selection, it will be the most responsive to the environment survive eventually. There is so much we can learn from the natural system. What I propose is not the bio-mimicry that only imitates the aesthetic of the nature but the study of the system which brings along the mutation in response to the change of environment.
QUOTE 1 - http://en.wikiquote.org/wiki/Charles_Darwin
Figure 1.0: http://2.bp.blogspot.com/ Diversity and complexity emerge through the process of natural selection and mutation.
Complex biological forms developed from very simple beginning, and natural selection was the means by which each species became more perfectly fitted to its environment. Michael Weinstock2 QUOTE 2 - pp. 22 The Architecture of Emergent The Evolution of Form in Nature and Civilisation, Weinstock, Wiley
1.2 THE COMPLEX SYSTEM A complex system is the resultant of the numerous interaction of individual entity with its immediate neighbours and with the environment. An individual entity may only perform a very simple task, however with the iteration of each individual entity responding to the environment, a complex system is emerged. A complex system is able to tackle the most difficult task which is impossible for a single entity to handle. A colony of termites will build a complex termite mould responsive to environmental changes which will enable the colony to survive as one system where single termite will never be able to survive on its own. Similar to the termite colony, the complex structure of the coral is formed by the iteration of millions of simple organisms.
1.2
1.1
1.3
Figure 1.1: http://www.reefcheckaustralia.org/adopt-a-coral-polyp.html Coral consisted of millions of siple organisms Figure 1.2: http://www.getintravel.com/adventure-travel-to-kakadu-national-park-in-australia Complex structure of the Termite Mounds Figure 1.3: http://en.wikipedia.org/wiki/Great_Barrier_Reef Barrier Reef is the largest single structure made by living organism
Figure 1.4: http://www.sciencephoto.com/ media/185854/enlarge/
Khara-Khoto in Inner Mongolia was once a thriving city of the Tangut Empire as described in Marco Polo's travel journal. However it was abandoned 700 years ago after its lifeline, the Black River was diverted. This is an example of cities failing to adopt to the change of the environment.
1.3 ARCHITECTURE
In Weinstock's Architecture of Emergence, Weinstock illustrates the resemblance between the evolution of nature and the evolution of civilisation. Cities reconstruct and expand overtime to adapt to the changes in environment. Similar to the process of natural selection where specie extinct if it fails to adapt to changes. Species diversify and evolutes to adapt to changes of its immediate environment. This results in an emergent system which constantly evolves to the reaching of equilibrium. With the advancement of technology and the power of computational simulation, a complex system could be incorporated into the design of architecture upon an equilibrium of the needs of the users with regards to to the ever changing environment is derived.
1.5
1.6
1.4 POTENTIAL
Computational design lends itself to an integral design approach as it enables employing complex behaviour rather than just modelling a particular shape or form. Weinstock3 The two structures explore the potential of computational simulation as a tool that formulate the design rather than a simple shaping tool. Technology allows greater integration of construction in the design process. With the availability of the material, the climate and the context of the site become the parameters formulating the design. The knowledge of parametric design also enables the digital fabrication of the material which reduces the time and number of skilled labours required for the construction. Contrast to the Membrane Canopy, the viewing platform utilises more mundane building materials with limited technology. The computational process enables the complexity of design similar to the AA membrane however with limited material and technology. QUOTE 3 - pp. 51 Emergent technologies and design: towards a biological paradigm for architecture, Hensel, Menges & Weinstock, Routledge
Figure 1.5: http://www.achimmenges.net/ AA Membrane Canopy, London 2007
Figure 1.6: http://www.achimmenges.net/ Viewing Platform and Shelter at Hacienda Quitralco, Patagonia, Chile 2007
1.7
URBAN AGENCY - ROLAND SNOOKS 1.7 "The proposition of the project is that an organism capable of autonomous or intelligent drift through the urban fabric is able to develop an emergent architectural form and organisation intrinsic or peculiar to its environment." kokkugia.com The resultant is the reaction of the agent to the environment and thus its behaviour. The agent constantly extracts and exchanges information with the environment and then evolves accordingly to the information extracted from the environment and eventually strikes an equilibrium.
2.0 COMPUTATIONAL SIMULATION
//2.1 Computation //2.2 Movement //2.3 Random Behaviour //2.4 Force //2.5 Oscillations //2.6 Particle System Background: http://ngm.nationalgeographic.com/2012/04/flamingos/nigge-photography Att flock of Flamingos
2.1 COMPUTATION
2.1
THE COMPUTATIONAL BEAUTY OF NATURE, GARY WILLIAM FLAKE, MIT PRESS Start with something so simple as not to seem worth stating and to end with something so paradoxical that no one will believe it. Bertrand Russell4 The essay introduces the concept of computational modelling of nature. Computational modelling will be the key to understand the complex system of nature. Despite the complexity of nature, it can be understood through a reductionistic approach which breaks down the system into multiple simple agent that interacts with each other. One of the examples of such approach is the study of DNA which eventually yields a better understanding of a complex system as a whole. Similar approach can also be used to understand the formation of emergent pattern in nature. This will allow us to comprehend the complex system in nature, and to employ the method to construct complex solution. The process of computational simulation utilises the system of 'iteration', 'recursion' and 'feedback' to achieve complexity. Such bottom up approach allows the generation of complexity and emergent behaviour which draws parallel to nature. Flake divides the theory of computational simulation into five different concepts: computation, fractal, chaos, complex system and adaption. Computation explores the limit of computer and what are the factors determining the function ability to be computed. Fractal explores how iterating equation can build up complexity. Chaos examines the random behaviour which leads to unpredictability in the long run. Complex system examines how interactions of simple agents within a system can lead to a complex solution. Finally, adaption allows the complex system to change, to learn and to evolve which ultimately mimic intelligence. QUOTE 4 - pp. 1The Computational Beauty of Nature, Gary William Flake, MIT Press 2.1 - pp. 7 The Computational Beauty of Nature, Gary William Flake, MIT Press
2.2 MOVEMENT
2.2
This processing sketch uses the bouncing balls sketch as a basis to develop the pixilated effect. The pixilated effect was achieved by moving the particles in the value of the width of the pirticles. This sketch also uses the object system to increase the number objects in the sketch. Same to the bouncing ball sketch, the object will bounce back once it hit the edges of the screen, this was achieved by multiplying the speed by negative 1. The speed of the objects are also randomized by the value of 1 to 10 pixels. Furthermore the colours of the objects are randomly drew from 3 preset colours.
2.3 RANDOM BEHAVIOR
RANDOM WALK
A
B
C
D
2.3
A
B
C
2.4
A
B
2.5
CONNECT
RANDOM WALK
RANDOM WALK 2.3 This sketch uses random walker as well as an array list function. The random walker function will be essential to develop spontaneous and organic behaviour that mimic the nature but it has limitation as it does not generate 'real' random numbers which formulate a pattern. 2.4 This sketch further explores the potential of the random walker. Each particle is initially located in a random location, then sprawl out randomly at a randomized speed. Same to the bouncing ball sketch, the particles bounce back in an opposite direction once it hits the edges of the screen. A line is then drawn when two particles are within a preset distance, and a triangle with randomized colour is drawn when there are three particles within a preset distance. 2.5 With the connecting lines and triangles, it gives a false impression of a 3 dimensional space though it is only a 2 dimensional sketch. With this sketch, an interesting object can be created if there is a logic behind the movement of the particles. The 'logic' or 'behaviour' will determine the path of movement and hence create an object that response to the particle itself.
LEVY FLIGHT
A
B
2.6
//Random Walk void move() { int xstep; int ystep; float choice = random (1); if (choice < 0.7){ //tendency to move randomly xstep = int(random(0,3))-1; //random walk for x ystep = int (random(0,3))-1; //random walk for y }else{ xstep = 1; //random walk for x ystep = 1; //random walk for y } x += xstep*xspeed; // acceleration y += ystep*yspeed;
LEVY FLIGHT
In the levy flight, the random walk behaviour of the agents is determined by probability. In the sketch, I set the probability at 70%. Which mean the agent will have 70% chance of performing a random walk and 30% chance of walking in straight line. The result is a trail consisting both random movement and straight line.
PERLIN NOISE
A
B
2.7
//CONSTRUCTOR Parti(){ loc = new PVector(random(width),random(height)); xstep = pow(-1,round(random(1,2))); //random walk for x ystep = pow(-1,round(random(1,2))); //random walk for y } //the power function here determine if the xstep or ystep valueis positive //or negative by using probability void move() { float angle = noise(loc.x/noiseScale,loc.y/noiseScale) * noiseStrength; loc.x += cos(angle) * xstep; loc.y += sin(angle) * ystep; //The Perlin Noise function
PERLIN NOISE
This sketch uses the Perlin Noise concept to determine the movement instead of complete randomness. The Perlin Noise is structured similar to audio signal, in respect to the function's use of frequency. The trail of the particles result into a more curve like and smooth pattern. The use of frequency enable the fluctuation number(randomness) in a curve like manner.
2.4 FORCE
MOUSE ATRACTION
2.8
void update() { // Compute a vector that points from location to mouse PVector mouse = new PVector(mouseX,mouseY); PVector acceleration = PVector.sub(mouse,location); // Set magnitude of acceleration //acceleration.setMag(0.2); acceleration.normalize(); acceleration.mult(0.1);
}
// Velocity changes according to acceleration velocity.add(acceleration); // Limit the velocity by topspeed velocity.limit(topspeed); // Location changes by velocity location.add(velocity);
2.9 GRAVITIONAL ATTRACTION
MOUSE ATTRACTION
This sketch explore the potential of the PVector function. The location of the mouse serves as the attractor for the particles and if the mouse is left clicked, the particles will be attracted to the cursor at an accelerated speed. This mimic the gravitional force attracting asteroid hitting or orbiting the planet. 2.9 - http://article.wn.com/view/2012/06/15/Asteroid_zips_past_Earth/ 2.10 - http://www.dailygalaxy.com/my_weblog/2011/04/-new-earth-companion-asteroid-discovered-in-an-odd-orbit.html
2.10 ORBIT
FRICTION & WIND
A
B
C
2.11
This sketch explore the potential of incorporating an external force to the objects. The force is applied toward the acceleration of the object according to its mass as F = m x a. The three forces introduced in this sketch are wind which pushed the objects horizontally, gravity to pull the objects downward and air friction to reduce its acceleration.
2.5 OSCILLATIONS
DOUBLE PENDULUM
A
B
C
D
E
F
2.12
//based on Shiffmanâ&#x20AC;&#x2122;s sketch Pendulum(PVector origin_, float r_) { // Fill all variables origin = origin_.get(); location = new PVector(); r = r_; angle = 5*PI/6; aVelocity = 0.0; aAcceleration = 0.0; damping = 0.999; // Arbitrary damping void go() { update(); display();
}
}
// Function to update location void update() { float gravity = 0.4; // Arbitrary constant aAcceleration = (-1 * gravity / r) * sin(angle); // Calculate acceleration (see: http://www.myphysicslab.com/pendulum1.html) aVelocity += aAcceleration; // Increment velocity aVelocity *= damping; // Arbitrary damping angle += aVelocity; // Increment angle } void display() { location.set(r*sin(angle), r*cos(angle), 0); // Polar to cartesian conversion location.add(origin); // Make sure the location is relative to the pendulumâ&#x20AC;&#x2122;s origin stroke(200,10); strokeWeight(0.5); // Draw the arm line(origin.x, origin.y, location.x, location.y); ellipseMode(CENTER); fill(250,80,random(150),150); // Draw the ball ellipse(location.x, location.y, 5, 5);}}
DOUBLE PENDULUM
This sketch examine the shift from the Cartesian vector coordinate (with x & y) to the polar vector coordinate with angle and the magnitude. This allow me to create sketch like the pendulum swing which require a polar system of coordinate to reference the pendulum and the location of the origin of the string. A second pendulum is then connect to the location of the first pendulum, the resultant is a double pendulum with dynamic movement.
ITERATION
Based on Daniel Shiffmanâ&#x20AC;&#x2122;s code class ParticleSystem { ArrayList<Particle> particles; PVector origin; PImage tex; ParticleSystem(int num, PVector v) { //constructor particles = new ArrayList(); origin = v.get(); // Store the origin point for (int i = 0; i < num; i++) { particles.add(new Particle(origin)); } } void run() { Iterator<Particle> it = particles. iterator(); while (it.hasNext()) { Particle p = it.next(); p.run(); if (p.dead()) { it.remove(); } } }
2.13
void addParticle() { particles.add(new Particle(origin)); } void addParticle(Particle p) { particles.add(p); } // test if the particle system still has particles boolean dead() { if (particles.isEmpty()) { return true; } else { return false; } } }
In this sketch I added the particle system class to manage the particles within the class. I introduce the variable of lifespan which gradually decrease its own value. And once it reaches zero, the particles is remove from the system. The removing and the continuous adding of particles allow the system to reach a state of equilibrium in a sense of a life cycle. And instead of drawing the particle with ellipse(), I use an image function to reference external image as the particle.
2.6 PARTICLE SYSTEM
AGENT BEHAVIOUR
A
B
C
D
2.14
SEPERATION
ATTRACTION
FLOCK
REPEL AGENT
2.15
A
B
C
A
B
C
2.16
2.17 A FLOCK OF FISHESAVOIDING THEIR PREDATOR
AGENT BEHAVIOUR
This sketch simulate a system with multiple agents reacting with each other. Each of the agents is given three set of different force which will be activate upon each other if the agents is within certain proximity of another agent. The attraction force attract the agents together, the separation force repel against the agents while flocking allow agents to follow the velocity direction of its neighbour. The sketch resemble the movement of pack animal such as flock of birds or fishes. in the second sketch I introduce a repel agents which move randomly and possess of a much larger separation force. This force away the original agents. The result resemble a flock fish evading its predators.
2.17 - http://www.docstoc.com/docs/891588/Black-and-White-School-of-Fish-PPT-Content-Theme-Slide
//base on Jose Sanchez’s tutorial void align(float magnitude){ Vec3D steer = new Vec3D(); int count = 0; for (int i = 0; i < particles.size(); i ++) { Parti other = (Parti) particles.get(i); float distance = loc.distanceTo(other.loc); if (distance > 0 && distance<30){ steer.addSelf(other.speed); //adding the ‘direction’ of the neighbouring particle count++; } } if (count > 0){ steer.scaleSelf(1.0/count); } steer.scaleSelf(magnitude); acc.addSelf(steer);} void cohesion(float magnitude) { Vec3D sum = new Vec3D(); int count = 0; for (int i = 0; i < particles.size(); i ++) { Parti other = (Parti) particles.get(i); float distance = loc.distanceTo(other.loc); if (distance > 0 && distance<70){ sum.addSelf(other.loc); count++; } } if (count > 0){ sum.scaleSelf(1.0/count); } Vec3D steer = sum.sub(loc); steer.scaleSelf(magnitude); acc.addSelf(steer); Vec3D stop = sum.sub(loc); stop.scaleSelf(magnitude); bacc.addSelf(stop);} void seperate(float magnitude){ Vec3D steer = new Vec3D(); int count = 0; for (int i = 0; i < particles.size(); i ++) { Parti other = (Parti) particles.get(i); float distance = loc.distanceTo(other.loc); if (distance > 0 && distance<40){ Vec3D diff = loc.sub(other.loc); diff.normalizeTo(1.0/distance); steer.addSelf(diff); count++; } } if (count > 0){ steer.scaleSelf(1.0/count); } steer.scaleSelf(magnitude); acc.addSelf(steer);} // the flee function reference the repell class void flee(float magnitude) { Vec3D stop = new Vec3D(); int count = 0; for (int i = 0; i < repell.size(); i++) { repellWalker temprepell = (repellWalker) repell.get(i); float distance = loc.distanceTo(temprepell.loc); if (distance > 0 && distance < 200) { Vec3D diff = loc.sub(temprepell.loc); diff.normalizeTo(1.0/distance); stop.addSelf(diff); count ++; } if (count > 0) { stop.scaleSelf(1.0/count); } stop.scaleSelf(magnitude); acc.addSelf(stop); } }
3.0 EMERGENT PROJECT
//3.1 Animal Architecture //3.2 Stigmergy //3.3 Precedents //3.4 Project 1 //3.5 Project 2 Background: http://6legs2many.wordpress.com/tag/solenopsis-invicta/ A mountain of exposed fire ants, mounded up on the brood pile to conserve moisture.
3.1 ANIMAL ARCHITECTURE
AGENT BEHAVIOUR & ANIMAL ARCHITECTURE Animals have been building impressive structures that response to the environment. How simple organism such as termite can construct such a complex system? We should look at the termite colony as a complex system comprise of numerous individual agents, we can see each agent perform simple task at the same time response to one another, and through the collective behaviour of the agents, a complex and emergent system is built. TERMITE MOULD 1.1 - A termite colony is a system comprises of different classes of termites performing different tasks - queen, warriors and workers. They communicate with each other by leaving a chemical trail with which information is exchanged and the colony articulated. The colony acts as a whole as a single organism performing multiple tasks, like fighting off intruders, finding food and building the mould. As an individual agents, each termite collects information of the environment and feeds back to the system. The mould is the result of the collaboration of the agents influenced by the information of the surrounding environment. SOCIABLE WEAVERS NEST 1.2 - Unlike the termite colony, the sociable weavers have a rather loose social structure. Each compartment of the nest normally comprises of two weavers and their offspring. The weavers do not feed in information into the system as the termites do. Their behaviour is influenced by the structure built upon by other weavers. In a sense, the weavers have a more individualistic behaviour. The collaboration of the weavers is therefore driven by mutual benefit of the individuals rather than the survival of the colony as a whole.
3.1 - http://science.howstuffworks.com/environmental/life/zoology/insects-arachnids/termite3.htm 3.2 - http://victoriayeager.com/social-weavers-namibia-africa-a-social-study/
3.1
3.2
3.2 STIGMERGY
Stigmergy is a form of self-organization in which it produces a complex and seemingly intelligent structure without any form of a 'grand planning' or control. Instead, it is a collaboration of some extremely simple agents. Each agent has a simple set of behaviours, and only reacts with its immediate neighbour. The resultant is an unpredictable and emergent pattern. One of the best examples of Stigmergy in nature is the 'path finding' and 'path following' behaviour of ants. Ants exchange information with each other by leaving 'pheromones' on its route to the nest of the colony after foraging for food. The pheromone stimulate ants passing by to follow the trail toward the food source, the ant then leave pheromone on its path with which the intensity of pheromones accumulated with more ants following the same path. Overtime, it creates a network of trails linking the nest and the food sources in the most efficient manner. Termites follow the similar method to build their complex nest. Stigmergy behaviour generates complex solution and emergent pattern and is one of the key concepts in the field of swarm intelligent. This could open up a new horizon and ultimately change the way we approach architecture. Architecture follows a top-down design approach. We 'design' the predetermined form, the predetermined structure and predetermined brief. Can we utilize stigmergy behaviour and swarm intelligent to generate complex solution which will better address the context of the environment and formulate an emergent design in architecture? The following projects of this chapter will explore the theory by developing sketches of computational simulation utilizing the coding language of processing.
3.4
3.3
3.5
3.7 3.6
3.3 PRECEDENTS
LEARNING FROM ANTS 3.3-4 - LYCS ARCHITECTURE RAILWAY PAVILION 2010 SHANGHAI EXPO 3.5-7 Learning from ants is a research initiated by LYCS to study the space created by the tunnelling ants. By observation, they study the behaviour of the ants, how the colony of ants interacts with each other. They then run a computational simulation adopting the ants' behaviour to the particles in the simulation. Based on the pattern created by the simulation, they designed the Railway Pavilion by using the pattern as the circulation of space. The concept behind the design is to use 'the ants' as a metaphoric mean to create dynamic space which is the result of the interactions amongst each occupant. 3.3-7 http://http://lycs-arc.com
3.8
3.9
WEB MORPHGENESIS - CHENGHAN YANG The project focuses on a research of non-hierarchical design system and what aesthetics such a system gives. It employed a non-linear system in which agents interact with each other to form an emergent pattern. The pattern (structure) of the design is the resultant of the local relationships between agents: attracting, detracting and repulsing effect amongst agents. The design is agents driven rather than a top-down approach. This allow the generation of complex and emergent pattern. 3.8-10 http://www.yangchenghan.com/
3.10
3.11
LET'S WORK TOGETHER A STIGMERGY APPROACH TO ACCOUSTIC DESIGN, JASON LIM 3.12
Multi-agent based design has been explored to achieve emergent and aesthetically pleasing architectural design. The complex system of agent based simulation can also achieve better understanding of the performance of architecture through the mean of simulation. This ultimately lead to a true 'performance driven' design. In this research, Lim explored the application of agent based modeling/simulation technique to the domain of acoustic design. The simulation is driven by the concept of stigmergy, of which stochastic agents(sound rays) are generated from sound source and the acoustic performance of the space is evaluated by mapping the interaction of rays with the seats and the structure. With the information fed in to the system, the geometry of the ceiling is then altered according to the information as part of the simulation process. Through multiple iterations, a state of equilibrium emerged with the ceiling geometry which has the optimum acoustic performance. 3.11 Viipuri Library, Alvar Aalto 3.12 Simulation base on the Viipuri Library 3.13 The alternation of the ceiling as the result of the simulation
3.11 http://www.public.iastate.edu/ 3.12-3 Let's Work Together - A STIGMERGY APPROACH TO ACCOUSTICESIGN, Jason LIM, ETH Zurich
3.13
3.4 PROJECT 1
REPEL ATTRACT
REPEL
ATTRACT
THE PROJECT - The goal of the project is to create a complex system comprising of multiple agents interacting with each other to form an emergent outcome. Right now the agents will attract to each other if they swarm into the 'blue zone' and repel against each other if they reach the 'red zone'. A variable is introduced for the lifespan of the agents, if the agent is within a certain distance with another agent, its lifespan decreases, and eventually becomes zero. If the lifespan is zero, the agent become static and possess of a greater attraction force. Eventually all the agents will become static and lines will be drawn between agents to 'document' the emergent result of the system. 3.14 the initial stage of the sketch, 3.15 the final outcome of the sketch, 3.16 Test on 3D
3.14
3.15
3.16
3.17
For 3.17-18 The looping of the backround is turned off to create the path of the movement of the particles from its initial stage to the final stage.
3.18
3.19
3.20
3.19-21 Using the iteration function to allow particle to be removed once its lifespan is exceed, then spawning new particles at random location.
3.21
3.5 PROJECT 2
//Base Image sketch by Gwyllim
The code here is a tweak of Gwyllim Jahn's code of the base image. The code here simulate the stigmergy behaviour through an array of particles. The particles leave a trails pheromone with its intensity determined by the brightness of the pixel of the base image on the very spot. The pheromone stimulate pass by particles to follow the trail. Initially the image fade function is turned on to allow the decrease of pheromone intensity over time. This allow the system to form an equilibrium where the pattern of the path becomes stable. I turn off the image fade function to study the relationship between the particles the pheromone trail instead.
//check the environment around the object void checkWorld(){ PVector toBest = new PVector(); //create a temp vector to keep track of the direction of the best condition float maxV = 0; //loop through pixels for (int i = -searchRad; i<=searchRad;i++){ for (int j = -searchRad; j<=searchRad;j++){ if(!(i==0 && j==0)){ //checks for edges int x = floor(location.x)+i; x = constrain(x,0,width-1); int y = floor(location.y)+j; y = constrain(y,0,height-1); //check to see if value //scale float v PVector
this is the smallest current by the distance to the value = world.getAt(x,y); toV = new PVector(i,j);
//limit the angle of vision if(PVector.angleBetween(toV,velocity)<PI/2){ //check to see if the current value is larger than the current best if((v)>maxV){ //reset all our variables that keep track of the best option float d = toV.mag(); toV.mult(1/d); toBest = toV; maxV = v;}}}}} //only effect if finding something above a tolerance if(maxV>20){ applyForce(toBest);}} void modWorld(){ //checks for edges if(lastPos.x<width-1 && lastPos.y<height-1 && lastPos.x>0 && lastPos.y >0) world.modAt(floor(lastPos.x),floor(lastPos.y),50);}}
100 particles
3.22
1000 particles
3.23
//A tweak of Gwyllim’s base image //new is particle ‘born’ if (pop.size()< numMovers) { pop.add(new Mover (new PVector(random(width),random(height)), new PVector(random(-maxSpeed,maxSpeed),random(-maxSpeed,maxSpeed)), 1));} //remove particles when it is ‘dead’ Iterator<Mover> it = pop.iterator(); while (it.hasNext()){ Mover m = it.next(); if(m.isDead())it.remove();}
The code here is the tweak of the base image sketch. I have added cohesion and separation force to the particles so that it will interact with each other. The forces are only activated if two particles are within certain radius. For the cohesion force, it's 70 pixels, while the separation force is 10 pixel. Therefore the particles is more likely to attract to each other, but repel against each once it reaches the threshold of the separation force. The third function I add here is the checkDis () function. If the distance between is less than the variable stated in the function, the variable 'lifespan' decrease and if lifespan is below zero, the particle is then removed. To create an equilibrium within the system, new particles are added if the number of particles is smaller than its initial size. For the following sketches, I have changed the intensity of the cohesion force, changed the initial spawning location of the particles to a fixed location and increased the number of the search radius.
///////////////////////////////////////// //check if the particle is dead boolean isDead() { if (lifespan <= 0.0) { return true; } else { return false;}} //Repel against each other void seperate(float magnitude){ PVector steer = new PVector(); int count = 0; for (int i = 0; i < pop.size(); i ++) { Mover other = (Mover) pop.get(i); float distance = location.dist(other.location); if (distance > 0 && distance<10){ PVector diff = location.get(); diff.sub(other.location); diff.normalize(); steer.add(diff); count++; } } if (count > 0){ steer.mult(1.0/count); } steer.mult(magnitude); acceleration.add(steer);} //attract each other void cohesion(float magnitude) { PVector sum = new PVector(); int count = 0; for (int i = 0; i < pop.size(); i ++) { Mover other = (Mover) pop.get(i); float distance = location.dist(other.location); if (distance > 0 && distance<70){ sum.add(other.location); count++; } } if (count > 0){ sum.mult(1.0/count); } sum.sub(location); sum.mult(magnitude); acceleration.add(sum); } void checkDis(){ for (int i = 0; i < pop.size(); i ++) { Mover other = (Mover) pop.get(i); float distance = location.dist(other.location); if (distance > 0 && distance<8){ lifespan-=55; } }}
A
3.24
Adding Cohesion and Seperation force
B
3.25
A
C
B
3.26
100 particles, turn off image fade
C
A
B
1000 particles, turn off image fade
3.27
B
A
3.28
1000 particles with stronger cohesion force
C
C New cluster
Spawning at same location Spawning off the edge 3.29
A
B
B
Spawning at same location without seperation and cohension force 3.30
A
B
A
3.31
Spawning at same location with image fade
Increase search radius Forming a continous path 3.32