Skip to content

Commit

Permalink
point list
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyBoivie authored and JimmyBoivie committed Dec 5, 2015
1 parent 33c8b61 commit b2277de
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 215 deletions.
6 changes: 3 additions & 3 deletions main/CompGeo.pde
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
public static class CompGeo {

public int CCW(Vertex a, Vertex b, Vertex c) {
public int CCW(Point a, Point b, Point c) {
// Return 1 if turn abc is ccw -1 if turn abc is cw 0 if no turn
float f = (b.getX() - a.getX())*(c.getY() - a.getY()) - (c.getX() - a.getX())*(b.getY()-a.getY());
if (f < 0) { return -1; }
if (f > 0) { return 1; }
return 0;
}

public int immediateCCW(Vertex parent, Vertex child, Vertex v1, Vertex v2) {
public int immediateCCW(Point parent, Point child, Point v1, Point v2) {
// returns 1 if v1 is more immediate CCW of parent, child than v2
// returns -1 if v2 is more immediate CCW of parent, child than v1
if (CCW(parent, child, v1) > CCW(parent, child, v2)) { return 1; }
if (CCW(parent, child, v1) < CCW(parent, child, v2)) { return -1; }
return CCW(parent, v1, v2);
}

}
}
11 changes: 11 additions & 0 deletions main/Point.pde
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ public class Point {
return y;
}

public HalfEdge getRef() {
return ref;
}

public void setRef(HalfEdge h) {
ref = h;
}

public boolean equals(float a, float b) {
return ((a == x) && (b == y));
}


// NEED METHOD GETTING ALL EDGES LEAVING POINT
}
20 changes: 20 additions & 0 deletions main/PointList.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
public class PointList {

private ArrayList<Point> points;

public PointList() {
points = new ArrayList<Point>();
}

public boolean contains(Point p) {
return points.contains(p);
}

public void addPoint(Point p) {
points.add(p);
}

public boolean removePoint(Point p) {
return points.remove(p);
}
}
155 changes: 0 additions & 155 deletions main/Vertex.pde

This file was deleted.

45 changes: 0 additions & 45 deletions main/VertexList.pde

This file was deleted.

24 changes: 12 additions & 12 deletions main/main.pde
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ public void setup() {
fill(0,0);
translate(width/2, height/2);
VertexList list = new VertexList();
Vertex v = new Vertex(0,0);
Vertex v1 = new Vertex(0,200);
Vertex v2 = new Vertex(80,100);
Vertex v3 = new Vertex(200,0);
Vertex v4 = new Vertex(-100,-100);
list.addVertex(v);
list.addVertex(v1);
list.addVertex(v2);
list.addVertex(v3);
list.addVertex(v4);
DrawHalfEdge draw = new DrawHalfEdge();
//Vertex v = new Vertex(0,0);
//Vertex v1 = new Vertex(0,200);
//Vertex v2 = new Vertex(80,100);
//Vertex v3 = new Vertex(200,0);
//Vertex v4 = new Vertex(-100,-100);
//list.addVertex(v);
//list.addVertex(v1);
//list.addVertex(v2);
//list.addVertex(v3);
//list.addVertex(v4);
//DrawHalfEdge draw = new DrawHalfEdge();
//HalfEdge h1 = new HalfEdge(v, v1);
//h1.facePrint();
//HalfEdge h2 = new HalfEdge(v, v3);
Expand All @@ -27,7 +27,7 @@ public void setup() {
//h1.facePrint();
//HalfEdge h5 = new HalfEdge(v1,v2);
//h1.facePrint();
draw.drawGraph(list.getVertexList());
//draw.drawGraph(list.getVertexList());
}
/*public void draw() {
fill(0,0,255,40);
Expand Down

0 comments on commit b2277de

Please sign in to comment.