Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Changed from ellipses to points (pshape to pvector).
  • Loading branch information
Andrew Lawson authored and Andrew Lawson committed Nov 29, 2014
1 parent dec9a90 commit 39fcb31
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions geometric_separators.pde
Expand Up @@ -12,7 +12,7 @@ int calc_h = 25;
PShape reset;
PShape calculate;
// Input list
ArrayList<PShape> input = new ArrayList<PShape>();
ArrayList<PVector> input = new ArrayList<PVector>();

// Setup
void setup() {
Expand All @@ -38,16 +38,16 @@ void mousePressed() {
// Get sorted input points
}
else {
PShape new_ellipse = createShape(ELLIPSE, mouseX - 12.5, mouseY - 12.5, 25, 25);
input.add(new_ellipse);
PVector new_point = new PVector(mouseX, mouseY);
input.add(new_point);
}
redraw();
}

// Estimate centerpoint
void approxCenter(ArrayList<PShape> input) {
void approxCenter(ArrayList<PVector> input) {
if (input.size() == 1) {
return ArrayList.get(0);
//return ArrayList.get(0);
}
else {
// Sample points
Expand All @@ -57,16 +57,16 @@ void approxCenter(ArrayList<PShape> input) {

// Estimate the geometric median - dynamic programming
void geomMedian() {
// Memoization hash tables
HashMap<Double> left = new HashMap<Double>():
HashMap<Double> right = new HashMap<Double>():
HashMap<Double> up = new HashMap<Double>():
HashMap<Double> down = new HashMap<Double>():
// Sum of squares values
ArrayList<Double> leftSq = new ArrayList<Double>();
ArrayList<Double> rightSq = new ArrayList<Double>();
ArrayList<Double> upSq = new ArrayList<Double>();
ArrayList<Double> downSq = new ArrayList<Double>();
// // Memoization hash tables
// HashMap<Double> left = new HashMap<Double>();
// HashMap<Double> right = new HashMap<Double>();
// HashMap<Double> up = new HashMap<Double>();
// HashMap<Double> down = new HashMap<Double>();
// // Sum of squares values
// ArrayList<Double> leftSq = new ArrayList<Double>();
// ArrayList<Double> rightSq = new ArrayList<Double>();
// ArrayList<Double> upSq = new ArrayList<Double>();
// ArrayList<Double> downSq = new ArrayList<Double>();
}

// Draw
Expand All @@ -76,8 +76,8 @@ void draw() {
shape(calculate);
text("Reset.", reset_x + 25, reset_y - 10);
text("Calculate.", calc_x + 25, calc_y - 10);
for (PShape ellipse : input) {
shape(ellipse);
fill(255);
for (PVector point : input) {
point(point.x, point.y);
strokeWeight(4);
}
}

0 comments on commit 39fcb31

Please sign in to comment.