Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Some fixes.
  • Loading branch information
Andrew Lawson authored and Andrew Lawson committed Dec 10, 2014
1 parent af83cfb commit f908d16
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions geometric_separators.pde
Expand Up @@ -72,7 +72,6 @@ PVector getRadonPoint(ArrayList<PVector> points) {
PVector radonPoint = null; PVector radonPoint = null;
radonPoint = inTetrahedron(points); radonPoint = inTetrahedron(points);
if (radonPoint == null) { if (radonPoint == null) {
System.out.println("Intersect");
radonPoint = intersectTri(points); radonPoint = intersectTri(points);
} }
return radonPoint; return radonPoint;
Expand Down Expand Up @@ -182,7 +181,6 @@ PVector testIntersect(PVector t1, PVector t2, PVector t3, PVector r1, PVector r2
float r = x / y; float r = x / y;
// No intersection // No intersection
if (r < 0) { if (r < 0) {
System.out.println("No intersect.");
return null; return null;
} }
rayDir.mult(r); rayDir.mult(r);
Expand All @@ -201,15 +199,12 @@ PVector testIntersect(PVector t1, PVector t2, PVector t3, PVector r1, PVector r2
float t = ((abDot * waDot) - (aDot * wbDot)) / d; float t = ((abDot * waDot) - (aDot * wbDot)) / d;
// Check if the point is outside // Check if the point is outside
if (s < 0 || s > 1) { if (s < 0 || s > 1) {
System.out.println("Outside.");
return null; return null;
} }
else if (t < 0 || (s + t) > 1) { else if (t < 0 || (s + t) > 1) {
System.out.println("Outside.");
return null; return null;
} }
// Otherwise it's inside we can return it // Otherwise it's inside we can return it
System.out.println("Inside");
return point; return point;
} }


Expand Down Expand Up @@ -329,6 +324,20 @@ PVector approxCenterpoint(ArrayList<PVector> input) {
// Draw // Draw
void draw() { void draw() {
background(255); background(255);
// Draw center point
if (centerPoint != null) {
stroke(255, 0, 0);
strokeWeight(6);
point(centerPoint.x, centerPoint.y);
stroke(0);
System.out.println("x-coordinate: " + Float.toString(centerPoint.x));
System.out.println("y-coordinate: " + Float.toString(centerPoint.y));
}
// Draw separator sphere projected to 2D
if (sphere != null) {
strokeWeight(6);
shape(sphere);
}
shape(reset); shape(reset);
shape(calculate); shape(calculate);
fill(50); fill(50);
Expand All @@ -343,16 +352,4 @@ void draw() {
point(point.x, point.y); point(point.x, point.y);
strokeWeight(2); strokeWeight(2);
} }
// Draw center point
if (centerPoint != null) {
strokeWeight(6);
point(centerPoint.x, centerPoint.y);
System.out.println("x-coordinate: " + Float.toString(centerPoint.x));
System.out.println("y-coordinate: " + Float.toString(centerPoint.y));
}
// Draw separator sphere projected to 2D
if (sphere != null) {
strokeWeight(6);
shape(sphere);
}
} }

0 comments on commit f908d16

Please sign in to comment.