Package de.fhpotsdam.unfolding.overviewdetail

Source Code of de.fhpotsdam.unfolding.overviewdetail.ConvexHullApp

package de.fhpotsdam.unfolding.overviewdetail;

import de.fhpotsdam.unfolding.examples.overviewdetail.connection.ConvexHull;
import processing.core.PApplet;
import processing.core.PVector;

/**
* Simple app to test convex hull algorithm.
*
* Click anywhere to add vertices. The convex hull is updated.
*
*/
public class ConvexHullApp extends PApplet {

  ConvexHull convexHull;

  public void setup() {
    size(500, 500);
    background(255);
    smooth();
   
    convexHull = new ConvexHull(this);
    convexHull.showDebugPoints = true;
    convexHull.addPoint(new PVector(random(width), random(height)));
    convexHull.addPoint(new PVector(random(width), random(height)));
    convexHull.addPoint(new PVector(random(width), random(height)));
  }

  public void draw() {
    background(255);
    convexHull.draw();
  }

  public void mousePressed() {
    convexHull.addPoint(new PVector(mouseX, mouseY));
  }

  public void keyPressed() {
    if (key == BACKSPACE) {
      convexHull.clearPoints();
    }
  }

}
TOP

Related Classes of de.fhpotsdam.unfolding.overviewdetail.ConvexHullApp

TOP
Copyright © 2018 www.massapi.com. 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.