diff --git a/geometric_separators.pde b/geometric_separators.pde index da78d7e..dcd989f 100644 --- a/geometric_separators.pde +++ b/geometric_separators.pde @@ -19,6 +19,8 @@ PShape reset; PShape calculate; PShape sphere; PVector centerPoint; +PVector sphereCenter; +float sphereRadius; ArrayList rawInput = new ArrayList(); // Object used for returning centerpoint and sphere @@ -49,6 +51,8 @@ void mousePressed() { rawInput.clear(); centerPoint = null; sphere = null; + sphereCenter = null; + sphereRadius = 0; } // If mouse presses calculate button else if ((mouseX >= calc_x && mouseX <= (calc_x + calc_w)) && @@ -271,11 +275,13 @@ float getRadius(PVector centerPoint, PVector unitVector) { float[] getSphereAttr(PVector centerPoint, PVector unitVector, float radius) { unitVector.mult(radius); centerPoint.sub(unitVector); - float[] attributes = {centerPoint.x, centerPoint.y, 2 * radius, 2 * radius}; + sphereCenter = new PVector(centerPoint.x, centerPoint.y, centerPoint.z); + sphereRadius = radius; + float[] attributes = {centerPoint.x, centerPoint.y, radius, radius}; return attributes; } -// Sample input points into sets of 4 +// Sample input points into sets of 5 ArrayList> samplePoints(ArrayList input) { ArrayList inputCopy = new ArrayList(input); ArrayList> setList = new ArrayList>(); @@ -336,6 +342,7 @@ void draw() { // Draw separator sphere projected to 2D if (sphere != null) { strokeWeight(6); + ellipseMode(RADIUS); shape(sphere); } shape(reset); @@ -349,7 +356,21 @@ void draw() { // Draw input for (PVector point : rawInput) { strokeWeight(8); - point(point.x, point.y); - strokeWeight(2); + if (sphereCenter != null) { + stroke(0, 0, 255); + point(sphereCenter.x, sphereCenter.y); + stroke(0); + if (point.x >= sphereCenter.x - sphereRadius && point.x <= sphereCenter.x + sphereRadius) { + if (point.y >= sphereCenter.y - sphereRadius && point.y <= sphereCenter.y + sphereRadius) { + stroke(0, 255, 0); + } + } + point(point.x, point.y); + } + else { + stroke(0); + point(point.x, point.y); + strokeWeight(2); + } } }