protected Particle returnIfConstrained(int index) { Particle p = (Particle) particles.get(index); for (int i = 0; i < constraints.size(); i++) { Particle other = (Particle) constraints.get(i); if (p.equalsWithTolerance(other, .1f)) { return other; } } return p; }
protected Particle returnIfDouble(Particle p) { for (int i = 0; i < particles.size(); i++) { Particle other = (Particle) particles.get(i); if (p.equals(other)) { return other; } } particles.add(p); return p; }
protected Particle returnIfConstrained(Particle p) { if (this.constraints != null) { for (int i = 0; i < constraints.size(); i++) { Particle other = (Particle) constraints.get(i); if (p.equalsWithTolerance(other, .1f)) { return other; } } } Particle particle = returnIfDouble(p); return particle; }