Week 11- Infrared

Concept:

For this week’s assignment, I was inspired by The Coding Train’s fire and falling sand simulations. I wanted to combine these ideas to create a fluid simulation where each particle behaves individually, like the falling sand, and interacts in a way that mimics fluid dynamics, similar to water ripples. I aimed to create an interactive experience where the particles respond to changes in velocity and density. As I started working on the project, the particles began to resemble smoke, with their movement and fading effect, which was visually interesting. Once I added color, the effect took on a glowing, infrared-like appearance, which inspired the project’s name.

Embedded Sketch:

Code I’m Proud Of:

One of the key pieces of code I’m most proud of is the particle fading effect and their interaction with one another. I implemented a system where particles gradually fade as they move, similar to smoke dissipating in the air. I also combined elements of fluid dynamics (from the coding train) and the falling sand simulation to make the particles interact naturally with each other. The movement of each particle is influenced by its neighbors, which makes the simulation more lifelike. The integration of color that simulates infrared light added a unique visual element that I found rewarding to develop.

let fluid;

function setup() {
   let canvas = createCanvas(600, 600); 
  canvas.style('filter', 'blur(0.5px)'); 
   frameRate(22);
   fluid = new Fluid(0.2, 0, 0.0000001);
}

function draw() {
  stroke(51);
  strokeWeight(2);

  let cx = int((0.5 * width) / SCALE);
  let cy = int((0.5 * height) / SCALE);
  for (let i = -1; i <= 1; i++) {
    for (let j = -1; j <= 1; j++) {
      fluid.addDensity(cx + i, cy + j, random(50, 150));
    }
  }

  for (let i = 0; i < 2; i++) {
    let angle = noise(t) * TWO_PI * 2;
    let v = p5.Vector.fromAngle(angle);
    v.mult(0.2);
    t += 0.01;
   fluid.addVelocity(cx, cy, v.x, v.y);
  }
  fluid.step();
  fluid.renderD();
}


function mousePressed() {
  let mx = int(mouseX / SCALE);
  let my = int(mouseY / SCALE);
  
  // Add density where the mouse is clicked
  fluid.addDensity(mx, my, random(100, 200));
  
  // Add a velocity to the clicked point to make the fluid move in a direction
  let angle = random(TWO_PI);
  let v = p5.Vector.fromAngle(angle);
  v.mult(0.5); // Adjust the force of the movement
  fluid.addVelocity(mx, my, v.x, v.y);
}

Key Features:

Some of the key features of the project include:

  • Interactive Particle Control: The user can influence the simulation by adding density and velocity to particles using the mouse.
  • Particle Interaction: Each particle responds to the others, creating a realistic fluid dynamic effect.
  • Fading Effect: Particles gradually fade out, simulating the natural behavior of smoke or fluid dissipating over time.
  • Color Simulation: The particles change color as they move, resembling infrared light or heat signatures, adding an extra layer of visual interest.

Reflection/Future Work:

I’m really happy with how the simulation turned out, especially the fluidity of the particles and their fading behavior. It was exciting to replicate the behavior of smoke and heat visually. Moving forward, I’d like to refine the particle interaction further, perhaps adding more complexity to the way particles influence each other. I’d also like to explore different types of particles or reactions, and experiment with creating more detailed textures or patterns within the simulation. Another area for improvement could be performance optimization, as simulations with many particles can become resource-intensive.

Resources:

The most helpful resources for this project were The Coding Train’s tutorials on fire and sand simulations, which served as a foundation for understanding how to simulate particle behavior. These resources helped me understand the technical aspects of simulating fluid-like behavior in a creative and interactive way.

Leave a Reply

Your email address will not be published. Required fields are marked *