I'm trying to get my particles to bounce off of the triangles that are created with each new sound. I know I need to somehow get the perimeter of the whole triangle so that i can calculate the distance between that and the particles, but I'm not sure how to do that. Any help would be greatly appreciated.
//1
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import processing.opengl.*;
ArrayList triparts;
//declare arraylist
ArrayList parts;
//2
Minim minim;
AudioInput input;
float a, a2;
void setup()
{
size(1000, 1000, OPENGL);
triparts = new ArrayList();
//construct arraylist
parts = new ArrayList();
//3
minim = new Minim(this);
//512 works as an array of ampllitude
input = minim.getLineIn(Minim.MONO, 360);
}
void draw()
{
background(67);
//4
a = abs(input.left.get(0))*20;
if (a > a2) {
a2 = a;
}
a2*=.3;
if (a2 > .9) {
for (int i = 0; i<1; i++)
{
triparts.add(new Peep());
}
}
for (int i = 0; i < triparts.size(); i++)
{
//pull the particle out of the arraylist - cast it as type "Particle"
Peep tri = (Peep) triparts.get(i);
tri.display();
tri.update();
}
}
noFill();
stroke(255, 100);
if (a2 > .5) {
for (int i = 0; i<30; i++)
{
parts.add(new Particle());
}
}
//use parts.size to get everything in arraylist
for (int i = 0; i < parts.size(); i++)
{
//pull the particle out of the arraylist - cast it as type "Particle"