Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Still working on 3D.
  • Loading branch information
Andrew Lawson authored and Andrew Lawson committed Dec 3, 2014
1 parent 0b66840 commit a0bba63
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions geometric_separators.pde
Expand Up @@ -173,7 +173,7 @@ void mousePressed() {
exampleList.add(ex7); exampleList.add(ex7);
exampleList.add(ex8); exampleList.add(ex8);
exampleList.add(ex9); exampleList.add(ex9);
exampleCenterPoint = new PVector(250, 250, 20000); exampleCenterPoint = new PVector(250, 250, 10000);
CenterAndSphere example = getExample(exampleCenterPoint); CenterAndSphere example = getExample(exampleCenterPoint);
exampleSphere = example.sphere; exampleSphere = example.sphere;
System.out.println(exampleSphere); System.out.println(exampleSphere);
Expand Down Expand Up @@ -265,8 +265,10 @@ CenterAndSphere getExample(PVector exampleCenterPoint) {
unitVector.x = Math.abs(unitVector.x); unitVector.x = Math.abs(unitVector.x);
unitVector.y = Math.abs(unitVector.y); unitVector.y = Math.abs(unitVector.y);
unitVector.z = Math.abs(unitVector.z); unitVector.z = Math.abs(unitVector.z);
System.out.println("Unit Vector...");
System.out.println(unitVector);
System.out.println(unitVector.mag());
float radius = getRadius(exampleCenterPoint, unitVector); float radius = getRadius(exampleCenterPoint, unitVector);
System.out.println(radius);
float[] sphereAttributes = getSphereAttr(exampleCenterPoint, unitVector, radius); float[] sphereAttributes = getSphereAttr(exampleCenterPoint, unitVector, radius);
PShape separator = createShape(ELLIPSE, sphereAttributes); PShape separator = createShape(ELLIPSE, sphereAttributes);
CenterAndSphere returnVals = new CenterAndSphere(exampleCenterPoint, separator); CenterAndSphere returnVals = new CenterAndSphere(exampleCenterPoint, separator);
Expand All @@ -285,7 +287,6 @@ CenterAndSphere getSeparator(ArrayList<PVector> input) {
unitVector.y = Math.abs(unitVector.y); unitVector.y = Math.abs(unitVector.y);
unitVector.z = Math.abs(unitVector.z); unitVector.z = Math.abs(unitVector.z);
System.out.println("Unit Vector..."); System.out.println("Unit Vector...");
System.out.println(unitVector);
// 3. Get radius // 3. Get radius
float radius = getRadius(centerPoint, unitVector); float radius = getRadius(centerPoint, unitVector);
// 4. Output sphere separator // 4. Output sphere separator
Expand All @@ -298,11 +299,7 @@ CenterAndSphere getSeparator(ArrayList<PVector> input) {
// Get radius for our separator // Get radius for our separator
float getRadius(PVector centerPoint, PVector unitVector) { float getRadius(PVector centerPoint, PVector unitVector) {
PVector centerPoint2D = new PVector(centerPoint.x, centerPoint.y); PVector centerPoint2D = new PVector(centerPoint.x, centerPoint.y);
System.out.println(centerPoint);
System.out.println(centerPoint2D);
float num = (float)Math.sqrt(Math.abs(centerPoint.z - Math.pow(centerPoint2D.mag(), 2))); float num = (float)Math.sqrt(Math.abs(centerPoint.z - Math.pow(centerPoint2D.mag(), 2)));
System.out.println(num);
System.out.println(unitVector.z);
return num / Math.abs(unitVector.z); return num / Math.abs(unitVector.z);
} }


Expand Down Expand Up @@ -505,13 +502,15 @@ void draw() {
fill(255); fill(255);
ellipseMode(CENTER); ellipseMode(CENTER);
shape(exampleSphere); shape(exampleSphere);
strokeWeight(2);
} }
if (exampleCenterPoint != null) { if (exampleCenterPoint != null) {
stroke(255, 0, 0); stroke(255, 0, 0);
strokeWeight(6); strokeWeight(6);
point(exampleCenterPoint.x, exampleCenterPoint.y); point(exampleCenterPoint.x, exampleCenterPoint.y);
System.out.println("x-coordinate: " + Float.toString(exampleCenterPoint.x)); System.out.println("x-coordinate: " + Float.toString(exampleCenterPoint.x));
System.out.println("y-coordinate: " + Float.toString(exampleCenterPoint.y)); System.out.println("y-coordinate: " + Float.toString(exampleCenterPoint.y));
strokeWeight(2);
stroke(0); stroke(0);
} }
shape(reset); shape(reset);
Expand All @@ -528,9 +527,11 @@ void draw() {
for (PVector point : rawInput) { for (PVector point : rawInput) {
strokeWeight(8); strokeWeight(8);
point(point.x, point.y); point(point.x, point.y);
strokeWeight(2);
} }
for (PVector point : exampleList) { for (PVector point : exampleList) {
strokeWeight(8); strokeWeight(8);
point(point.x, point.y); point(point.x, point.y);
strokeWeight(2);
} }
} }

0 comments on commit a0bba63

Please sign in to comment.