Package processing.core

Examples of processing.core.PVector


   */
  public static Location getCentroid(List<Location> originalVertices) {
    List<Location> vertices = getClosedPolygon(originalVertices);
    float cx = 0f, cy = 0f;
    for (int i = 0; i < vertices.size() - 1; i++) {
      PVector vi0 = vertices.get(i);
      PVector vi1 = vertices.get(i + 1);
      cx = cx + (vi0.x + vi1.x) * (vi0.x * vi1.y - vi0.y * vi1.x);
      cy = cy + (vi0.y + vi1.y) * (vi0.x * vi1.y - vi0.y * vi1.x);
    }
    float area = getArea(vertices);
    cx /= (6f * area);
 
View Full Code Here


   * @return The area.
   */
  public static float getArea(List<Location> vertices) {
    float sum = 0;
    for (int i = 0; i < vertices.size() - 1; i++) {
      PVector vi0 = vertices.get(i);
      PVector vi1 = vertices.get(i + 1);
      sum += (vi0.x * vi1.y - vi1.x * vi0.y);
    }
    return sum * 0.5f;
  }
 
View Full Code Here

   */
  protected boolean isInside(float checkX, float checkY,
      List<? extends PVector> vectors) {
    boolean inside = false;
    for (int i = 0, j = vectors.size() - 1; i < vectors.size(); j = i++) {
      PVector pi = vectors.get(i);
      PVector pj = vectors.get(j);
      if ((((pi.y <= checkY) && (checkY < pj.y)) || ((pj.y <= checkY) && (checkY < pi.y)))
          && (checkX < (pj.x - pi.x) * (checkY - pi.y) / (pj.y - pi.y) + pi.x)) {
        inside = !inside;
      }
    }
View Full Code Here

    this.innerOffsetX = width / 2 - TILE_WIDTH / 2;
    this.innerOffsetY = height / 2 - TILE_HEIGHT / 2;

    registerTilesLoadedMethod();

    setInnerTransformationCenter(new PVector(width / 2 + offsetX, height / 2 + offsetY));

    calculateMatrix();

    calculateInnerMatrix();
  }
View Full Code Here

    noFill();
    ellipse(pos.x, pos.y, 10, 10);
  }

  public void keyPressed() {
    rotateCenter = new PVector(mouseX, mouseY);

    // Inner rotate (i.e. map) works with both, P2D and GLGraphics
    map.mapDisplay.setInnerTransformationCenter(rotateCenter);
    if (key == 'r') {
      map.rotate(-PI / 8);
View Full Code Here

   */
  public void zoomAndPanTo(float x, float y, int level) {
    // NB: Could not be deprecated as switching float/int parameters would be ambiguous!

    // Works only when first zoom around pos, then pan to pos
    mapDisplay.setInnerTransformationCenter(new PVector(x, y));
    zoomToLevel(level);
    panTo(x, y);
  }
View Full Code Here

  @Override
  public void distort(PVector origCoord, PVector distCoord, int value) {
    float origRadius = PVector.dist(center, origCoord);
    float newRadius = interpolateRadius(origRadius);

    PVector orgFromCenter = new PVector(0, 0, 0);
    PVector.sub(origCoord, center, orgFromCenter);
    float n = PApplet.map(newRadius, 0, origRadius, 0, 1);
    orgFromCenter.mult(n);

    PVector.add(orgFromCenter, center, distCoord);
  }
View Full Code Here

   * @param screenPosition
   *            ScreenPosition to zoom around and pan to.
   */
  public void zoomAndPanTo(int level, ScreenPosition screenPosition) {
    // Works only when first zoom around pos, then pan to pos
    mapDisplay.setInnerTransformationCenter(new PVector(screenPosition.x, screenPosition.y));
    zoomToLevel(level);
    panTo(screenPosition.x, screenPosition.y);
  }
View Full Code Here

   * @param location
   *            The Location to zoom around and pan to.
   */
  public void zoomAndPanTo(int zoomLevel, Location location) {
    ScreenPosition pos = mapDisplay.getScreenPosition(location);
    mapDisplay.setInnerTransformationCenter(new PVector(pos.x, pos.y));
    zoomToLevel(zoomLevel);
    panTo(location);
  }
View Full Code Here

  public void zoomAndPanToFit(List<Location> locations) {
    Location[] boundingBox = GeoUtils.getBoundingBox(locations);
    List<Location> boundingBoxLocations = Arrays.asList(boundingBox);
    Location centerLocation = GeoUtils.getEuclideanCentroid(boundingBoxLocations);
    ScreenPosition pos = mapDisplay.getScreenPosition(centerLocation);
    mapDisplay.setInnerTransformationCenter(new PVector(pos.x, pos.y));
    zoomToFit(boundingBox);
    panTo(centerLocation);
  }
View Full Code Here

TOP

Related Classes of processing.core.PVector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.