/** * Subtract one vector from another * @param v1 the x, y, and z components of a PVector object * @param v2 the x, y, and z components of a PVector object */ static public PVector sub(PVector v1, PVector v2) { return sub(v1, v2, null); }
/** * Subtract one vector from another * @param v1 the x, y, and z components of a PVector object * @param v2 the x, y, and z components of a PVector object */ static public PVector sub(PVector v1, PVector v2) { return sub(v1, v2, null); }
public void setPrevPos(PVector prevPosition) { pposition = prevPosition; speed = PVector.sub(prevPosition, position); }
public void setPosition(float x, float y, float z) { this.pposition.set(this.position); this.position.x = x; this.position.y = y; this.position.z = z; this.speed.set(PVector.sub(this.position, this.pposition)); }
protected float computeRotation(Touch touch0, Touch touch1) { PVector currentDirection = PVector.sub(touch0.pposition, touch1.pposition); PVector previousDirection = PVector.sub(touch0.position, touch1.position); currentDirection.normalize(); previousDirection.normalize(); float cos = currentDirection.dot(previousDirection); float angle = acos(cos); PVector sin = currentDirection.cross(previousDirection); if (sin.z < 0) { angle = -angle; } return angle; }
/** * Update the position of this element according to the parameter. Updates * the position, previous position, confidence and speed. * * @param tp */ private void updatePosition(TrackedElement tp) { // save the previous position previousPosition = position.get(); this.position.set(tp.position); this.confidence = tp.confidence; // this.setSource(tp.source); speed.set(this.position); speed.sub(this.previousPosition); }
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; }
viewedPtC.sub(originC);