Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix intersection bugs
  • Loading branch information
JimmyBoivie authored and JimmyBoivie committed Dec 7, 2015
1 parent a23825c commit cedb66d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions main/CompGeo.pde
Expand Up @@ -28,7 +28,7 @@ public static class CompGeo {
if ((CCW(a,b,c) != CCW(a,b,d)) && ((CCW(c,d,a) != CCW(c,d,b)))) {
return 1;
}
if ((CCW(a,b,c) == 0) & (CCW(a,b,d) == 0)) {
if ((CCW(a,b,c) == 0) && (CCW(a,b,d) == 0)) {
if (between(a,c,b) || between(a,d,b) || between(c,a,d) || between(c,b,d)) {
return 1;
}
Expand Down Expand Up @@ -158,4 +158,4 @@ public static class CompGeo {
}
return null;
}
}
}
13 changes: 9 additions & 4 deletions main/HalfEdge.pde
Expand Up @@ -269,10 +269,15 @@ public class HalfEdge {
}

private boolean intersectsEventually(Point p, Point q) {
if (this.getOrigin().equals(p)) { return false; }
if (this.getOrigin().equals(q)) { return false; }
if (CompGeo.intersect(p, q, this.getOrigin(), this.gettwin().getOrigin()) == 1) {
return true;
boolean shared = false;
if (this.getOrigin().equals(p)) { shared = true; }
if (this.getOrigin().equals(q)) { shared = true; }
if (this.gettwin().getOrigin().equals(p)) { shared = true; }
if (this.gettwin().getOrigin().equals(q)) { shared = true; }
if (shared == false) {
if (CompGeo.intersect(p, q, this.getOrigin(), this.gettwin().getOrigin()) == 1) {
return true;
}
}
if (counted == false) {
counted = true;
Expand Down
2 changes: 2 additions & 0 deletions main/main.pde
Expand Up @@ -133,7 +133,9 @@ public void insertMode(float x, float y) {
if(p.getY() - 10 < pointclicked.getY() && p.getY() + 10 > pointclicked.getY()
&& p.getX() - 10 < pointclicked.getX() && p.getX() + 10 > pointclicked.getX()) { }
else {
if (!list.intersectsSomething(p, pointclicked)) {
HalfEdge h = new HalfEdge(p, pointclicked);
}
}
}
}
Expand Down

0 comments on commit cedb66d

Please sign in to comment.