/** * @param v the vector to multiply by the scalar */ static public PVector mult(PVector v, float n) { return mult(v, n, null); }
/** * @param v the vector to multiply by the scalar */ static public PVector mult(PVector v, float n) { return mult(v, n, null); }
void flock(ArrayList uninfected, ArrayList infected) { PVector sep = separate(uninfected); // Separation PVector ali = align(uninfected); // Alignment PVector coh = cohesion(uninfected); // Cohesion PVector pan = panic(infected); // Panic // Arbitrarily weight these forces sep.mult(4.0); ali.mult(1.0); coh.mult(2.0); pan.mult(-3.0); // Add the force vectors to acceleration acc.add(sep); acc.add(ali); acc.add(coh); acc.add(pan); }
for (int i = 0; i < movers.length; i++) { float c = 0.01; PVector friction = movers[i].velocity.get(); friction.mult(-1); friction.normalize(); friction.mult(c); movers[i].applyForce(friction); movers[i].applyForce(wind); movers[i].applyForce(gravity); movers[i].update(); movers[i].display(); movers[i].checkEdges(); }
/** * Sets the magnitude of this vector, storing the result in another vector. * @param target Set to null to create a new vector * @param len the new length for the new vector * @return a new vector (if target was null), or target */ public PVector setMag(PVector target, float len) { target = normalize(target); target.mult(len); return target; }
/** * Sets the magnitude of this vector, storing the result in another vector. * @param target Set to null to create a new vector * @param len the new length for the new vector * @return a new vector (if target was null), or target */ public PVector setMag(PVector target, float len) { target = normalize(target); target.mult(len); return target; }
public RSTTransform(PVector size) { this.sceneTranslate = size.get(); this.sceneTranslate.mult(0.5f); }
/** * ( begin auto-generated from PVector_setMag.xml ) * * Set the magnitude of this vector to the value used for the <b>len</b> parameter. * * ( end auto-generated ) * * @webref pvector:method * @usage web_application * @param len the new length for this vector * @brief Set the magnitude of the vector */ public void setMag(float len) { normalize(); mult(len); }
/** * ( begin auto-generated from PVector_setMag.xml ) * * Set the magnitude of this vector to the value used for the <b>len</b> parameter. * * ( end auto-generated ) * * @webref pvector:method * @usage web_application * @param len the new length for this vector * @brief Set the magnitude of the vector */ public PVector setMag(float len) { normalize(); mult(len); return this; }
protected PVector computeTranslate(Touch touch0, Touch touch1) { PVector previousCenter = PVector.add(touch0.pposition, touch1.pposition); previousCenter.mult(0.5f); PVector currentCenter = PVector.add(touch0.position, touch1.position); currentCenter.mult(0.5f); PVector diff = PVector.sub(currentCenter, previousCenter); // diff.mult(0.5f); return diff; }
/** * ( begin auto-generated from PVector_limit.xml ) * * Limit the magnitude of this vector to the value used for the <b>max</b> parameter. * * ( end auto-generated ) * * @webref pvector:method * @usage web_application * @param max the maximum magnitude for the vector * @brief Limit the magnitude of the vector */ public void limit(float max) { if (magSq() > max*max) { normalize(); mult(max); } }
/** * ( begin auto-generated from PVector_limit.xml ) * * Limit the magnitude of this vector to the value used for the <b>max</b> parameter. * * ( end auto-generated ) * * @webref pvector:method * @usage web_application * @param max the maximum magnitude for the vector * @brief Limit the magnitude of the vector */ public PVector limit(float max) { if (magSq() > max*max) { normalize(); mult(max); } return this; }
protected void twoFingerMovement() { if (!getValidTouchs()) { emptyUpdate(); return; } // System.out.println("Full Update"); // Every values needs to be divided by 2... for some reason. float rot = computeRotation(touchs[0], touchs[1]); if (!Float.isNaN(rot)) // && abs(rot) > PI / 90f) { addRotation(rot / 2f); } float scale = computeScale(touchs[0], touchs[1]); if (!Float.isNaN(scale)) // && abs(scale) > 0.8) { float halfScale = (scale - 1f) / 2f + 1; multScale(halfScale); } PVector translate = computeTranslate(touchs[0], touchs[1]); translate.mult(0.5f); addTranslation(translate); }
dir.mult(4); // Scale acceleration = dir;