/** * Set the position of the capture in millimeter. * * @param x * @param y */ public void setCaptureOffset(float x, float y) { this.captureOffset.set(x, y); }
/** * Use either TopLeftCorner OR BottomLeftCorner. Calling one will discard * the other. * * @param topLeftCorner */ public void setTopLeftCorner(PVector topLeftCorner) { this.topLeftCorner.set(topLeftCorner); this.isYUp = false; }
/** * Use either TopLeftCorner OR BottomLeftCorner. Calling one will discard * the other. * * @param bottomLeftCorner */ public void setBottomLeftCorner(PVector bottomLeftCorner) { this.bottomLeftCorner.set(bottomLeftCorner); this.isYUp = true; }
/** * Add a 2D offset to the touch. * * @param touchOffset */ public void setTouchOffset(PVector touchOffset) { this.touchOffset.set(touchOffset); }
/** * Set the capture size in millimeters. * * @param x * @param y */ public void setCaptureSize(float x, float y) { this.captureSize.set(x, y); }
public void setCaptureSizeMM(PVector captureSizeMM) { this.captureSizeMM.set(captureSizeMM); }
/** * Multiply a vector by a scalar, and write the result into a target PVector. * @param target PVector in which to store the result */ static public PVector mult(PVector v, float n, PVector target) { if (target == null) { target = new PVector(v.x*n, v.y*n, v.z*n); } else { target.set(v.x*n, v.y*n, v.z*n); } return target; }
/** * Add two vectors into a target vector * @param target the target vector (if null, a new vector will be created) */ static public PVector add(PVector v1, PVector v2, PVector target) { if (target == null) { target = new PVector(v1.x + v2.x,v1.y + v2.y, v1.z + v2.z); } else { target.set(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); } return target; }
/** * Subtract one vector from another and store in another vector * @param target PVector in which to store the result */ static public PVector sub(PVector v1, PVector v2, PVector target) { if (target == null) { target = new PVector(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); } else { target.set(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); } return target; }
/** * Add a 2D offset to the touch. * * @param x * @param y */ public void setTouchOffset(float x, float y) { this.touchOffset.set(new PVector(x, y)); }
/** * Multiply a vector by a scalar, and write the result into a target PVector. * @param target PVector in which to store the result */ static public PVector mult(PVector v, float n, PVector target) { if (target == null) { target = new PVector(v.x*n, v.y*n, v.z*n); } else { target.set(v.x*n, v.y*n, v.z*n); } return target; }
/** * Divide a vector by a scalar and store the result in another vector. * @param target PVector in which to store the result */ static public PVector div(PVector v, float n, PVector target) { if (target == null) { target = new PVector(v.x/n, v.y/n, v.z/n); } else { target.set(v.x/n, v.y/n, v.z/n); } return target; }
/** * Set a new position to this tracked element, it will save the past * location and compute the speed. * * @param pos */ public void setPosition(Vec3D pos) { this.position.set(pos.x, pos.y, pos.z); setPreviousPosition(); }
/** * Set a new position to this tracked element, it will save the past * location and compute the speed. * * @param pos */ public void setPosition(PVector pos) { this.position.set(pos); setPreviousPosition(); }
public void setPosition(PVector pos) { this.pos.set(pos); if (boardView != null) { boardView.setTopLeftCorner(pos); } }
/** * Divide a vector by a scalar and store the result in another vector. * @param target PVector in which to store the result */ static public PVector div(PVector v, float n, PVector target) { if (target == null) { target = new PVector(v.x/n, v.y/n, v.z/n); } else { target.set(v.x/n, v.y/n, v.z/n); } return target; }
/** * Add two vectors into a target vector * @param target the target vector (if null, a new vector will be created) */ static public PVector add(PVector v1, PVector v2, PVector target) { if (target == null) { target = new PVector(v1.x + v2.x,v1.y + v2.y, v1.z + v2.z); } else { target.set(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); } return target; }
/** * Make a new 2D unit vector from an angle * * @param target the target vector (if null, a new vector will be created) * @return the PVector */ static public PVector fromAngle(float angle, PVector target) { if (target == null) { target = new PVector((float)Math.cos(angle),(float)Math.sin(angle),0); } else { target.set((float)Math.cos(angle),(float)Math.sin(angle),0); } return target; }
public PVector mult(PVector source, PVector target) { if (target == null) { target = new PVector(); } target.set(m00*source.x + m01*source.y + m02*source.z + m03, m10*source.x + m11*source.y + m12*source.z + m13, m20*source.x + m21*source.y + m22*source.z + m23); // float tw = m30*source.x + m31*source.y + m32*source.z + m33; // if (tw != 0 && tw != 1) { // target.div(tw); // } return target; }