Skip to content
Permalink
Browse files

Fixed some bugs.

  • Loading branch information
Andrew Lawson Andrew Lawson
Andrew Lawson authored and Andrew Lawson committed Dec 11, 2014
1 parent ae84960 commit 311772e2394cea4249a62284a56420b25709a69a
Showing with 17 additions and 5 deletions.
  1. +17 −5 geometric_separators.pde
@@ -71,6 +71,7 @@ void mousePressed() {
PVector point = new PVector(x, y, 0);
PVector pointLifted = new PVector(point.x, point.y, (float)Math.pow(point.mag(), 2));
rawInput.add(pointLifted);
System.out.println(rawInput.size());
}
}
// If mouse presses calculate button
@@ -80,7 +81,8 @@ void mousePressed() {
System.out.println("You need at least 5 points!");
return;
}
else if ((Math.log((double)rawInput.size()) / Math.log(5)) % 1 != 0) {
else if ((Math.log10((double)rawInput.size()) / Math.log10(5)) % 1 > 0.00000001) {
System.out.println((Math.log10(rawInput.size()) / Math.log10(5) % 1));
System.out.println("You don't have a power of 5!");
return;
}
@@ -103,14 +105,19 @@ PVector getRadonPoint(ArrayList<PVector> points) {
PVector radonPoint = null;
radonPoint = inTetrahedron(points);
if (radonPoint == null) {
System.out.println("TRIANGLE");
radonPoint = intersectTri(points);
return radonPoint;
}
else {
System.out.println("TETRA");
return radonPoint;
}
return radonPoint;
}

// Tests if a point is within a tetrahedron
PVector inTetrahedron(ArrayList<PVector> points) {
PVector radonPoint = null;
PVector radonPoint;
for (int i = 0; i < points.size(); i++) {
ArrayList<PVector> pointsCopy = new ArrayList<PVector>(points);
PVector testPoint = pointsCopy.get(i);
@@ -139,7 +146,7 @@ PVector inTetrahedron(ArrayList<PVector> points) {
return radonPoint;
}
}
return radonPoint;
return null;
}

// Tests if a ray intersects a triangle
@@ -166,7 +173,7 @@ PVector intersectTri(ArrayList<PVector> points) {
return point;
}
// Triangle of Points 1, 3, 5
point = testIntersect(points.get(0), points.get(2), points.get(4), points.get(2), points.get(3));
point = testIntersect(points.get(0), points.get(2), points.get(4), points.get(1), points.get(3));
if (point != null) {
return point;
}
@@ -190,6 +197,11 @@ PVector intersectTri(ArrayList<PVector> points) {
if (point != null) {
return point;
}
// Triangle of Points 3, 4, 5
point = testIntersect(points.get(2), points.get(3), points.get(4), points.get(0), points.get(1));
if (point != null) {
return point;
}
return null;
}

0 comments on commit 311772e

Please sign in to comment.
You can’t perform that action at this time.