<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with #particle - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23particle</link>
      <pubDate>Sun, 08 Aug 2021 19:17:46 +0000</pubDate>
         <description>Tagged with #particle - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23particle/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How to do this using color tracking?</title>
      <link>https://forum.processing.org/two/discussion/22769/how-to-do-this-using-color-tracking</link>
      <pubDate>Fri, 26 May 2017 09:55:40 +0000</pubDate>
      <dc:creator>JJJJJJ</dc:creator>
      <guid isPermaLink="false">22769@/two/discussions</guid>
      <description><![CDATA[<p>please tell us how to draw this code.</p>

<p>We want to draw some particle.
at this moment, the particle should be drawn on the color that we tracking.</p>

<p>the particle that we want to draw is as in the following.</p>

<p>the main tap is ↓</p>

<pre><code>/**
 * Simple Particle System
 * by Daniel Shiffman.  
 * 
 * Particles are generated each cycle through draw(),
 * fall with gravity and fade out over time
 * A ParticleSystem object manages a variable size (ArrayList) 
 * list of particles. 
 */

ParticleSystem ps;

void setup() {
  size(640,360);
  ps = new ParticleSystem(new PVector(width/2,50));
}

void draw() {
  background(0);
  if(mousePressed)
  {  ps.updateOrigin(new PVector(mouseX, mouseY)); }

  ps.addParticle();
  ps.run();
}
</code></pre>

<p>and the second tap is ↓</p>

<pre><code>// A simple Particle class

class Particle {
  PVector location;
  PVector velocity;
  PVector acceleration;
  float lifespan;

  Particle(PVector l) {
    acceleration = new PVector(0,0.05);
    velocity = new PVector(random(-1,1),random(-2,0));
    location = l.copy();
    lifespan = 255.0;
  }

  void run() {
    update();
    display();
  }

  // Method to update location
  void update() {
    velocity.add(acceleration);
    location.add(velocity);
    lifespan -= 1.0;
  }

  // Method to display
  void display() {
    stroke(255,lifespan);
    fill(255,lifespan);
    ellipse(location.x,location.y,8,8);
  }

  // Is the particle still useful?
  boolean isDead() {
    if (lifespan &lt; 0.0) {
      return true;
    } else {
      return false;
    }
  }
}
</code></pre>

<p>and the third tap is ↓</p>

<pre><code>// A class to describe a group of Particles
// An ArrayList is used to manage the list of Particles 

class ParticleSystem {
  ArrayList&lt;Particle&gt; particles;
  PVector origin;

  ParticleSystem(PVector location) {
    origin = location.copy();
    particles = new ArrayList&lt;Particle&gt;();
  }

  void addParticle() {
    //particles.add(new Particle(new PVector(mouseX, mouseY)));
    particles.add(new Particle(origin));
  }

  void run() {
    for (int i = particles.size()-1; i &gt;= 0; i--) {
      Particle p = particles.get(i);
      p.run();
      if (p.isDead()) {
        particles.remove(i);
      }
    }   
  }

  void updateOrigin(PVector newOrigin)
  { origin = newOrigin.copy(); }
</code></pre>

<p>}<img src="https://forum.processing.org/two/uploads/imageupload/836/FXPC7DBDCUPS.png" alt="KakaoTalk_20170526_184753062" title="KakaoTalk_20170526_184753062" /></p>
]]></description>
   </item>
   <item>
      <title>Spherical constantForceBehavior Toxiclibs Particle</title>
      <link>https://forum.processing.org/two/discussion/21600/spherical-constantforcebehavior-toxiclibs-particle</link>
      <pubDate>Sat, 25 Mar 2017 05:26:23 +0000</pubDate>
      <dc:creator>ConnorMCG</dc:creator>
      <guid isPermaLink="false">21600@/two/discussions</guid>
      <description><![CDATA[<p>Who can demonstrate how to apply a spherical force behavior to a 3D toxiclibs particle? Key hangup is creating a spherical force behavior as opposed to a vector... Thanks!</p>
]]></description>
   </item>
   <item>
      <title>how to improve performance for particle systems</title>
      <link>https://forum.processing.org/two/discussion/18565/how-to-improve-performance-for-particle-systems</link>
      <pubDate>Sat, 15 Oct 2016 19:43:04 +0000</pubDate>
      <dc:creator>flowen</dc:creator>
      <guid isPermaLink="false">18565@/two/discussions</guid>
      <description><![CDATA[<p>dear creatives,</p>

<p>I'm building a particle system, based on Daniel Shiffman's code from nature of code. Drawing triangle vertices when distance is within the defined range. Quite fast I get massive fps drops, which i sort of expected as it's 3 loops within each other.</p>

<p>I've been briefly told about binned particle system, for which I could only find some old thread containing dead links. <a href="https://forum.libcinder.org/topic/kyle-mcdonald-s-binned-particle-system" target="_blank" rel="nofollow">https://forum.libcinder.org/topic/kyle-mcdonald-s-binned-particle-system</a></p>

<p>I wonder if there are other known techniques like this and if you know some resources or perhaps even a tutorial ;)</p>

<p>Thx in advance</p>
]]></description>
   </item>
   <item>
      <title>How do I write a particle system to evolve to form an uploaded black and white image?</title>
      <link>https://forum.processing.org/two/discussion/18238/how-do-i-write-a-particle-system-to-evolve-to-form-an-uploaded-black-and-white-image</link>
      <pubDate>Thu, 22 Sep 2016 00:27:36 +0000</pubDate>
      <dc:creator>great_gravity</dc:creator>
      <guid isPermaLink="false">18238@/two/discussions</guid>
      <description><![CDATA[<p>I want to start out with a window of randomly placed particles and have them generation by generation, form into the shape of an image made up of only Black and White values. The population will be different particle systems. Their "fitness score" will be based on the similarity to the target image. How do I compare the pixels in the processing window to that of an uploaded image?</p>
]]></description>
   </item>
   <item>
      <title>class parameters</title>
      <link>https://forum.processing.org/two/discussion/17453/class-parameters</link>
      <pubDate>Thu, 07 Jul 2016 21:33:12 +0000</pubDate>
      <dc:creator>phaidon</dc:creator>
      <guid isPermaLink="false">17453@/two/discussions</guid>
      <description><![CDATA[<p>hello i have taken the standar particle system with the texture,and i want to give the location of the mouse in draw function rather inside the class because i want to connect it with kinect,tried it but the result was strange,i tried to move the acceleration and the velocity,the result is better but it is still strange.i tried to move also the the lifespan parameter but it is also strange. Im thinking that is something with the add particle function and the iterator,but im not very good with tha concept,to figure out the problem.I will be very thankful if you can help me.Thank you in advance</p>

<p>here is the code:</p>

<pre><code>import java.util.Iterator;
ParticleSystem ps;
PVector location;
PVector acceleration;
PVector velocity;
float lifesp = 255;
float _lifesp = 2.0;

void setup(){
 size(640,360,P2D);
PImage image = loadImage("texture.png");
ps = new ParticleSystem(image);


}

void draw(){
 background(0);
 //ps.applyForce();
 acceleration = new PVector(0, 0.05);
    velocity = new PVector(random(-1, 1), random(-2, 0));
 PVector location = new PVector (mouseX,mouseY);
 lifesp -= _lifesp;
ps.run(location, acceleration, velocity,lifesp );
ps.addParticle();


}
</code></pre>

<p>the particle class:</p>

<pre><code>class Particle {


  PVector loc;
  PVector location;

  float lifespan;
PImage image;




  Particle(PImage img) {



    image = img;
  }

  void run(PVector location ,PVector _acceleration, PVector _velocity,float _lifespan) {

    update(location,_acceleration,_velocity);
    display(location,_lifespan);
  }

  void update(PVector _location, PVector _acceleration, PVector _velocity) {

    velocity.add(_acceleration);
    _location.add(_velocity); 

  }


  void display(PVector _location, float _lifespan) {

    stroke(0, lifespan);
    imageMode(CENTER);
    tint(255,lifespan);
    image(image,_location.x,_location.y);
    //fill(175, lifespan);
    //ellipse(location.x, location.y, 8, 8);
  }

  boolean isDead(float _lifespan) {
    lifespan = _lifespan;
    if (_lifespan &lt; 0.0) { 
      return true;
    } else {
      return false;
    }
  }
}
</code></pre>

<p>and the particle system class:</p>

<pre><code>class ParticleSystem{

 ArrayList&lt;Particle&gt; particles;
PVector origin;

//PVector _loc;

PImage image;

ParticleSystem(PImage _img){

  particles = new ArrayList&lt;Particle&gt;();
  image = _img;

} 

  void addParticle(){
   particles.add(new Particle(image)); 


  }

  void run(PVector location, PVector acceleration, PVector velocity,float _lifespan){
   Iterator&lt;Particle&gt; it = particles.iterator();
  while (it.hasNext()){

   Particle p = it.next();
   p.run(location,acceleration,velocity, _lifespan);
   if(p.isDead(_lifespan)){
     println("khgkhk");
    it.remove(); 
   }
  } 

  }


}`
</code></pre>
]]></description>
   </item>
   <item>
      <title>Stop Particles From Being Erased</title>
      <link>https://forum.processing.org/two/discussion/10683/stop-particles-from-being-erased</link>
      <pubDate>Thu, 07 May 2015 05:34:43 +0000</pubDate>
      <dc:creator>Shaker</dc:creator>
      <guid isPermaLink="false">10683@/two/discussions</guid>
      <description><![CDATA[<p>I'm pretty new at this so please excuse my bad terminology. I have a project that requires every frame to be redrawn for the animation of particles and fluid then to fade them after creation but I want to add a background particle effect that every particle stays on the screen until the sketch is stopped. I have everything working and appearing on screen but the background branching particle effect is redrawn and thus only the newest particles appear and unfortunately overlay the animated particles.</p>

<p>Is there any way to draw the background branch particles behind the fluid and to keep them from being erased every frame without effecting the fluid fade?</p>
]]></description>
   </item>
   <item>
      <title>Multiple Particle Systems in One Sketch</title>
      <link>https://forum.processing.org/two/discussion/10664/multiple-particle-systems-in-one-sketch</link>
      <pubDate>Wed, 06 May 2015 04:37:18 +0000</pubDate>
      <dc:creator>Shaker</dc:creator>
      <guid isPermaLink="false">10664@/two/discussions</guid>
      <description><![CDATA[<p>Hello All,</p>

<p>I'm fairly new to processing and coding all together but am trying to teach myself as fast as possible. I'm working on a interactive project in my collective using a kinect and processing. I already have a particle and particle system that interacts with the kinect in my sketch but I want to add a second particle as the background specifically a plexus. My question is how do I go about adding a second separate set of particles that don't interact with the current particle system.</p>

<p>As I said I am really new and sure this is a super newbie question but any help would be greatly appreciated. 
Thanks,</p>
]]></description>
   </item>
   <item>
      <title>How to use particles</title>
      <link>https://forum.processing.org/two/discussion/10300/how-to-use-particles</link>
      <pubDate>Mon, 13 Apr 2015 23:31:18 +0000</pubDate>
      <dc:creator>RifleGirl</dc:creator>
      <guid isPermaLink="false">10300@/two/discussions</guid>
      <description><![CDATA[<p>So for a visualization of data I want a specific number of particles to move in a constrained area and then when the space bar is pressed move to another specific area and have the particles move in a different constrained space.</p>

<p>How would you do this and also change the number of particles in these constrained areas (go from 60 to 50).</p>
]]></description>
   </item>
   <item>
      <title>particles react on audio</title>
      <link>https://forum.processing.org/two/discussion/10317/particles-react-on-audio</link>
      <pubDate>Tue, 14 Apr 2015 19:20:00 +0000</pubDate>
      <dc:creator>Vriplum</dc:creator>
      <guid isPermaLink="false">10317@/two/discussions</guid>
      <description><![CDATA[<p>I don't know if this is the right place to post this, but I have a code that creates particles ( eclipes) when there is sound.
So it react with the microphone. I found this code on the internet and edited it a little bit.
Now I would like the particles to react on music. ( no microphone) Some words in this code are Dutch, I hope that's not a problem. Sorry for my bad English.</p>

<pre><code>import ddf.minim.*;

AudioPlayer player;
AudioInput input;
Minim minim;
AudioInput in;
float volume = 0;
float volumeF = 0;

int maxParticles=300; // max number of particles. real particles count depends on ppf and its lifetime
int addPPF=2;         // number of particles per frame added
ArrayList particles;

void setup(){
  size(1000,1000);
  frameRate(30);
  smooth();
  background(255);
  noStroke();
      minim = new Minim(this);
  player = minim.loadFile("aventry-fire.mp3", 2048);
  player.play();

  // get a line in from Minim, default bit depth is 16
  in = minim.getLineIn(Minim.MONO, 512);


  particles = new ArrayList();
}

void draw(){
  background(0); // overpaint circles the frame before
  //  for(int i = 0; i &lt; 1; i++)
  //{
     volumeF = in.right.level()*1000;
  volume = 0.7*volume + 0.1*volumeF;
  if(particles.size()&lt;maxParticles){
    /** add particle(s) */
    for(int k=1; k&lt;= volume; k++){
      particles.add(new Particles());
    }
  }
  //}

  /** run trought all Balls and make some action */
  for(int j=0; j&lt;particles.size(); j++){
    Particles particle = (Particles)particles.get(j);
    /** if particle still alive */
    if( particle.alive() ){
      /** update x/y positions */
      particle.position();
      /** now draw as cirle */
      //fill(255,0,0, particle.lt);

     if(key == '1'){
        fill(0,255,0, particle.lt);
        text("verander kleur",10,50);

     }
     if(key == '2'){
        fill(0,255,255, particle.lt);
         text("verander kleur",10,50);
     }
     if(key == '3'){
        fill(255,255,0, particle.lt);
         text("verander kleur",10,50);
     }
     if(key == '4'){
        fill(0,0,255, particle.lt);
         text("verander kleur",10,50);
     }
     if(key == '5'){
        fill(random(255),random(255),random(255), particle.lt);
        text("verander kleur",10,50);
     }
      if(key == '6'){
        fill(random(255),random(255),random(255));
        text("verander kleur",10,50);
     }

     if(key== 'q'){
       text("Reageer op geluid",10,50);
      if(volume&gt;0){
         fill(0,0,255, particle.lt);

       } 
      if(volume&gt;3){
         fill(255,255,255, particle.lt);
       } 
       if(volume&gt;6){
         fill(0,255,255, particle.lt);
       }
       if(volume&gt;9){
         fill(255,0,255, particle.lt);
       }
       if(volume&gt;12){
         fill(255,255,0, particle.lt);
       }
       if(volume&gt;15){
         fill(255,100,100, particle.lt);
       }

      }


     if(key == 'a'){
       text("Vierkantjes",10,50);
       rect(particle.x, particle.y, particle.r, particle.r);}
    else{
     ellipse(particle.x, particle.y, particle.r, particle.r);  
   }


  }else{
      /** if lifetime is running out, delete */
      particles.remove(j);
    }
  }
}


  void stop()
{
  // always close Minim audio classes when you are done with them
  in.close();
  minim.stop();

  super.stop();
}

public class Particles {
  float r, x, y, _x, _y, dx=0, dy=0, lt;

  /** init start-values */
  public Particles() {
    /** start position center */
    x=width/2;
    y=height/2;
    /** now random values to make it non-linear */
    lt=random(50,100);       // lifetime in frames
    r=random(20, 50);        // circle Radius
    _x=random(-0.5, 0.5);    // stepwidth in x-pos (left, right)
    _y=random(-0.5, 0.5);    // stepwidth in y-pos (up, down)

    if(key == 'w'){
    text("Volg muis",10,50);
    x=mouseX;
    y=mouseY;
    }

  if(key == 's'){
    _x=random(-4,-0);    // stepwidth in x-pos (left, right)
    _y=random(-2, 2); 

  }

   if(key == 'd'){
    _x=random(0,4);    // stepwidth in x-pos (left, right)
    _y=random(-4, 4); 

  }
  if(key == 'z'){
    text("verander Snelheid",10,50);
     _x=random(-2.5,4);    // stepwidth in x-pos (left, right)
    _y=random(-2.5,4 ); 
  }
 if(key == 'x'){
   text("verander grootte",10,50);
   r=random(50, 120); 

 }
    }

    void stop(){
  player.close();
  minim.stop();

}

  public void position() {
    /** stepwidth increases, circlespeed is exponential */
    dx+=_x;
    dy+=_y;
    x+=dx;
    y+=dy;
  }

  public boolean alive(){
     if(lt&lt;=0){ return false; }else{ lt--; return true; }
  }


}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Iterating through all elements but the first one</title>
      <link>https://forum.processing.org/two/discussion/7652/iterating-through-all-elements-but-the-first-one</link>
      <pubDate>Thu, 16 Oct 2014 16:24:49 +0000</pubDate>
      <dc:creator>jozze</dc:creator>
      <guid isPermaLink="false">7652@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I am trying to iterate through a list of particles to apply later some motion to them, the first one must remain static. 
I´ve thought about using both enhanced and 'classic' for loop; the first one was rejected, since it iterates through all elements of the array, while the second one throws an <em>"indexOutOfBoundsException;index:4,Size:4"</em> It seems to be a very naive solution but I haven´t figure it out yet; is there something I am missing or any other more suitable loop I could go through? Thanks for answers. Here is part of the code:</p>

<pre><code>        Constructor(){
        //blabla
        ..
            Particle first=particles.get(0);
            first.lock(); 
        //blabla
        ..
        }

            void display() {
            //blabla
            ..
 //for (Particle p : particles) {  //rejected

                   for (int i = particles.size();i&gt;=1; i++) {//we start from i&gt;=1 so 1st particle remains fixed  ??   
                      Particle p= particles.get(i); 
                //blabla
             ellipse(p.x, p.y, 2, 2);
    ..

                }
</code></pre>
]]></description>
   </item>
   <item>
      <title>blend option error in 3d</title>
      <link>https://forum.processing.org/two/discussion/7207/blend-option-error-in-3d</link>
      <pubDate>Wed, 17 Sep 2014 09:04:46 +0000</pubDate>
      <dc:creator>raphmeelo</dc:creator>
      <guid isPermaLink="false">7207@/two/discussions</guid>
      <description><![CDATA[<p>hello everyone!
i've encountered an unespected problem turning a particle system in a 3d space.
in this case i've built a 2d circular orbit with a red png as particle that goes around smoothing like a comet.
i put the (ADD) blending mode but when i rotate the orbit in the 3d space (on the Y axis) the blend screws up.</p>

<p>look at this screenshot with the same particle system at three different rotation, with the same blend mode</p>

<p>after that i also tried to change the 2d particle with a 3d, but all i've obtained is 3 spheres turning around with no trails.</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/111/G00C7JON6GU0.png" alt="Schermata 2014-09-17 alle 12.00.43" title="Schermata 2014-09-17 alle 12.00.43" /></p>
]]></description>
   </item>
   <item>
      <title>Generative drawing / Particles</title>
      <link>https://forum.processing.org/two/discussion/6821/generative-drawing-particles</link>
      <pubDate>Mon, 18 Aug 2014 18:38:19 +0000</pubDate>
      <dc:creator>atoro</dc:creator>
      <guid isPermaLink="false">6821@/two/discussions</guid>
      <description><![CDATA[<p><span class="VideoWrap"><span class="Video YouTube" id="youtube-r3m_wCW6Qcc"><span class="VideoPreview"><a href="http://youtube.com/watch?v=r3m_wCW6Qcc"><img src="http://img.youtube.com/vi/r3m_wCW6Qcc/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span></p>
]]></description>
   </item>
   <item>
      <title>Particle system (classes) + mousePressed or mouseDragged (of a single particle) = impossible ...?</title>
      <link>https://forum.processing.org/two/discussion/6540/particle-system-classes-mousepressed-or-mousedragged-of-a-single-particle-impossible</link>
      <pubDate>Tue, 29 Jul 2014 16:50:47 +0000</pubDate>
      <dc:creator>A__</dc:creator>
      <guid isPermaLink="false">6540@/two/discussions</guid>
      <description><![CDATA[<p>I'm ultimately trying to click a particle and be able to drag it around the screen.</p>

<p>I'm building off the <a rel="nofollow" href="http://processing.org/examples/simpleparticlesystem.html">SimpleParticleSystem example</a>.</p>

<p>Things like<code>void mouseDragged()</code> can't be carried out in classes. So one must call them from the main sketch, which is simple enough... except that I'm working with a particle system (array list) composed of 2 classes (1 describes the particle group, 1 describes the particle itself), which is creating lots of problems for me.</p>

<p>I found <a rel="nofollow" href="http://processing.org/discourse/beta/num_1196111865.html">this thread</a> describing how to implement void mousePressed in classes, but the example answer that apparently worked for the asker did not work with my particles.</p>

<p>I'm able to freeze and capture the exact coordinates of a moving particle on hover, and even identify it's sequence in the array, but when it comes to using variables from one class in the other, I just end up getting static vs non-static field errors or null pointer exceptions.</p>

<p>It'd take me probably an hour to sort out my code to present my specific problems (and I can't really think anymore today :P), so I'd just like to know:</p>

<p>Is it even possible to have such interaction with a particle system; to be able to single a particle out (i.e. on click) and manipulate it independently (i.e. drag it around)?</p>

<p>Has anyone here done this before?</p>

<p>Does it require "hacking" around the particle system somehow (i.e. creating a new object on top of the particle and manipulating that instead of the particle itself)?</p>

<p>Thanks in advance for any feedback, hopefully this will help me move forward so I can come up with a more sensible question.</p>
]]></description>
   </item>
   <item>
      <title>Distance between particles always ends up with zero?</title>
      <link>https://forum.processing.org/two/discussion/4854/distance-between-particles-always-ends-up-with-zero</link>
      <pubDate>Fri, 02 May 2014 02:37:56 +0000</pubDate>
      <dc:creator>unparadise</dc:creator>
      <guid isPermaLink="false">4854@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I am playing with particle system and am trying to create a group of particles within which each particle is connected to the particle that's closest in distance with a line. However, when I use the for loop and the dist() function to find the shortest distance, the returned result is for some reason always zero.</p>

<p>Could someone help me understand why this is happening? I have pasted my code below.</p>

<p>Thank you for your time in advance.</p>

<p>-Frank</p>

<hr />

<pre><code>ArrayList particles = new ArrayList();
int closest_i = 0;
float d = 400;

void setup() {
  size(400, 200);
  background(50);
  smooth();

  fill(255);
  textSize(90);
  text("NEON", 30, 130);

  for (int x = 0; x &lt; width; x++) {
    for (int y = 0; y &lt; height; y++) {
      if (get(x, y) == color(255)) {
        // number to control the number of particles generated
        if(random(1) &lt; 0.05) {
          particles.add(new Particle(x, y));
        }
      }
    }
  }
}

void draw() {
  background(50);

  for (int i = 0; i &lt; particles.size(); i++) {
    Particle p1 = (Particle) particles.get(i);
    p1.display();
    p1.update();

    for(int j = 0; j &lt; particles.size(); j++) {
      if(i != j) {
        Particle p2 = (Particle) particles.get(j);
        float dt = dist(p1.x, p1.y, p2.x, p2.y);
        if(dt &lt; d) {
          d = dt;
          closest_i = j;
          println("d: " + d);
          println("closest index: " + closest_i);
          println("-------------------------");
        }
      }
    }

    //println("index: " + i + ", " + "closest: " + closest_i);
    Particle pc = (Particle) particles.get(closest_i);
    stroke(28, 152, 232, 20);
    line(p1.x, p1.y, pc.x, pc.y);
  }
}

class Particle {
  float x, y;

  Particle(float x0, float y0) {
    x = x0;
    y = y0;
  }

  void display() {
    stroke(28, 152, 232);
    point(x, y);
  }

  void update() {
    x += floor(random(-1, 2));
    y += floor(random(-1, 2));
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>[Solved] Returning NaN, why ?</title>
      <link>https://forum.processing.org/two/discussion/4475/solved-returning-nan-why</link>
      <pubDate>Thu, 17 Apr 2014 06:48:38 +0000</pubDate>
      <dc:creator>blyk</dc:creator>
      <guid isPermaLink="false">4475@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am trying to create a charge particle system where when you click left mouse it creates negative charge and right click creates positive charge.  You can add as many as positive and negative charges.</p>

<p>The problem in my code is when I try to calculate the ditance between the two charges it returns NaN and when I check for NaN as in line number 63 it returns some float values so I figured out that when I try calculating the force and accl it returns NaN but when float.NaN(d) is ture the d returns some value.</p>

<pre><code>ArrayList&lt;Charge&gt; poop = new ArrayList();
void setup() {
  size(300, 200);
}

float k =  1; // 8.98E+9; //  8.9875517873681764×10^9
void draw() {
  background(0);
  for (int i=0;i&lt;poop.size();i++) {
    Charge q = (Charge)poop.get(i);
    q.show();
    q.update();
    q.applyForce(q);
  }
}

void mousePressed() {
  int t=1;
  if (mouseButton == RIGHT) t = 1;
  if (mouseButton == LEFT) t = -1;
  Charge C = new Charge(t, mouseX, mouseY);
  poop.add(C);
}

class Charge {
  PVector loc;
  PVector vel;
  PVector acc;
  float k =  1;
  float state = 1;//1.60E-19; //  1.602176487×10−19
  color c;

  Charge(int t, int x, int y) {
    loc = new PVector(x, y);
    vel = new PVector(0, 0);
    acc = new PVector(0, 0);
    //acc = new PVector(random(-0.05, 0.05), random(-0.05, 0.05));
    state*=t;
    c = (color) random(#000000);
  }

  void show() {
    noFill();
    strokeWeight(2);
    stroke(c);
    ellipse(loc.x, loc.y, 20, 20);
    setCharge();
  }

  void update() {
    vel.add(acc);
    vel.limit(1);
    loc.add(vel);
  }

  void applyForce(Charge C) {

    for (int i=0;i&lt;poop.size();i++) {
      Charge Q = (Charge)poop.get(i);
      PVector dir = PVector.sub(Q.loc, C.loc);
      float d = dir.mag();
      println(" d: " + d);
      if (!Float.isNaN(d)) {
        float force = (k*Q.state*C.state)/d*d;
        dir.mult(force);
        acc.add(dir);
      }
    }

  }

  void setCharge() {
    pushMatrix();
    translate(loc.x, loc.y);
    if (state&lt;0)line(-5, 0, 5, 0);
    else {
      line(0, -5, 0, 5); 
      line(-5, 0, 5, 0);
    }
    popMatrix();
  }
}

boolean flag=false;
void keyPressed() {
  flag = !flag;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>[Solved] Particle Text: Need help !</title>
      <link>https://forum.processing.org/two/discussion/4436/solved-particle-text-need-help</link>
      <pubDate>Wed, 16 Apr 2014 07:17:35 +0000</pubDate>
      <dc:creator>xenomorph</dc:creator>
      <guid isPermaLink="false">4436@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
Can anyone tell me how to create text with particles? Just explain me so that I can develop my own code. I have seen so many code on openprocessing but I was unable to understand.</p>
]]></description>
   </item>
   <item>
      <title>Stimula, interactive plant</title>
      <link>https://forum.processing.org/two/discussion/2618/stimula-interactive-plant</link>
      <pubDate>Fri, 24 Jan 2014 05:37:51 +0000</pubDate>
      <dc:creator>alexr4</dc:creator>
      <guid isPermaLink="false">2618@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone,</p>

<p>We have just release our last interactive project, Stimula, and want to share it with you.</p>

<p>It’s a real time interpretation of information generated by a plant while reacting to human and environmental stimuli. 
The piece which combines generative, sound and interactive design brings to the light the fact that the plant is a living organism. In this setup, the plant is no longer considered as a simple decoration object.</p>

<p>I hope you will enjoy it.</p>

<p><div class="VideoWrap"><div class="Video Vimeo"><object width="640" height="385"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=84847448&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=84847448&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="385"></embed></object></div></div>﻿</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/485/VIUHOF6D8T42.jpg" alt="12100356593_eb6cafa3f3_z" title="12100356593_eb6cafa3f3_z" /></p>
]]></description>
   </item>
   </channel>
</rss>