/** * {@inheritDoc} * Ignores any z component. */ public PVector mult(PVector source, PVector target) { if (target == null) { target = new PVector(); } target.x = m00*source.x + m01*source.y + m02; target.y = m10*source.x + m11*source.y + m12; return target; }
@Override public PVector getNormal(int index, PVector vec) { if (vec == null) { vec = new PVector(); } vec.x = inGeo.normals[3 * index + 0]; vec.y = inGeo.normals[3 * index + 1]; vec.z = inGeo.normals[3 * index + 2]; return vec; }
//MoveTest topSpeed = 5.0; //update velocity.add(acceleration); if(stop == false) { velocity.limit(topSpeed); //south acceleration = new PVector(0,5);
@Override public PVector getVertex(int index, PVector vec) { if (vec == null) { vec = new PVector(); } vec.x = inGeo.vertices[3 * index + 0]; vec.y = inGeo.vertices[3 * index + 1]; vec.z = inGeo.vertices[3 * index + 2]; return vec; }
public PVector[] getCorners() { PVector[] out = new PVector[4]; out[0] = new PVector((float) corners[0], (float) corners[1]); out[1] = new PVector((float) corners[2], (float) corners[3]); out[2] = new PVector((float) corners[4], (float) corners[5]); out[3] = new PVector((float) corners[6], (float) corners[7]); return out; }
public PVector getNormal(int index, PVector vec) { if (vec == null) { vec = new PVector(); } vec.x = vertices[index][PGraphics.NX]; vec.y = vertices[index][PGraphics.NY]; vec.z = vertices[index][PGraphics.NZ]; return vec; }
private void initiateImageCoordinates() { imagePixelCoordinates.clear(); imagePixelCoordinates.add(new PVector(0, imageHeightPx)); imagePixelCoordinates.add(new PVector(imageWidthPx, imageHeightPx)); imagePixelCoordinates.add(new PVector(imageWidthPx, 0)); imagePixelCoordinates.add(new PVector(0, 0)); }
PVector[] points = new PVector[4]; // Define a PVector array containing the points of the shape points[0] = new PVector(0, 0); // Start at bottom left points[1] = new PVector(random(512), 0); // The normal width is 512, the normal height 1024 points[2] = new PVector(random(512), random(1024)); // y coordinates are from bottom to top! points[3] = new PVector(0, random(1024)); f.addGlyph('A').addContour(points); // Assign contour to character A
PVector[] points = new PVector[4]; // Define a PVector array containing the points of the shape points[0] = new PVector(0, 0); // Start at bottom left points[1] = new PVector(random(512), 0); // The normal width is 512, the normal height 1024 points[2] = new PVector(random(512), random(1024)); // y coordinates are from bottom to top! points[3] = new PVector(0, random(1024)); f.addGlyph('A').addContour(points);
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
public PVector projectPointer(PaperScreen paperScreen, float x, float y) { PMatrix3D screenMat = paperScreen.getLocation(new PMatrix3D()); screenMat.invert(); PVector transformed = new PVector(); screenMat.mult(new PVector(x * drawingSizeX, y * drawingSizeY), transformed); transformed = new PVector(transformed.x / paperScreen.getDrawingSize().x, transformed.y / paperScreen.getDrawingSize().y); return transformed; }
public PVector worldToPixel(PVector pt, boolean undistort) { // Reprojection float invZ = 1.0f / pt.z; int px = PApplet.constrain(PApplet.round((pt.x * invZ * fx) + cx), 0, w - 1); int py = PApplet.constrain(PApplet.round((pt.y * invZ * fy) + cy), 0, h - 1); if (undistort && this.handleDistorsion) { double[] out = device.distort(px, py); return new PVector((float) out[0], (float) out[1]); } else { return new PVector(px, py); } }
public PVector createRayFrom(PVector pixels) { double[] out = device.undistort(pixels.x, pixels.y); float norm = PApplet.sqrt(PApplet.pow((float) out[0], 2) + PApplet.pow((float) out[1], 2) + 1.0f); PVector v = new PVector((float) out[0] / norm, (float) out[1] / norm, 1.f / norm); return v; }