Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…oproject

merging with jimmy's updates
  • Loading branch information
cor11004 committed Dec 15, 2015
2 parents c73f043 + fedfdb1 commit 284754e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
44 changes: 44 additions & 0 deletions main/HalfEdge.pde
Expand Up @@ -245,6 +245,48 @@ public class HalfEdge {
}
}

public HalfEdge findStart(float x, float y, float distance, Point farAway) {
HalfEdge temp = findHalfEdgeSelected(x,y,distance, farAway);
reset();
return temp;
}

public HalfEdge findHalfEdgeSelected(float x, float y, float distance, Point farAway) {
if (this.isSelected(x,y,distance, farAway)) { return this; }
if (counted != false) {
counted = true;
HalfEdge temp = twin.findHalfEdgeSelected(x,y,distance,farAway);
if (temp != null) { return temp; }
temp = next.findHalfEdgeSelected(x,y,distance,farAway);
if (temp != null) { return temp; }
temp = previous.findHalfEdgeSelected(x,y,distance,farAway);
if (temp != null) { return temp; }
}
return null;
}

public boolean isSelected(float x, float y, float distance, Point farAway) {
Point p1 = new Point(origin.getX(), origin.getY());
Point p3 = new Point(twin.getOrigin().getX(), twin.getOrigin().getY());
float midx = (p1.getX() + p3.getX())/2;
float midy = (p1.getY() + p3.getY())/2;
float dx = p1.getX() - p3.getX();
float dy = p1.getY() - p3.getY();
float ndx = -dy;
float ndy = dx;
float notScaled = sqrt(ndx*ndx + ndy*ndy);
float scale = notScaled/distance;
ndx = ndx/scale;
ndy = ndy/scale;
Point p2 = new Point(midx + ndx, midy + ndy);
Point p4 = new Point(midx - ndx, midy - ndy);
HalfEdge h1 = new HalfEdge(p1, p2);
HalfEdge h2 = new HalfEdge(p2, p3);
HalfEdge h3 = new HalfEdge(p3, p4);
HalfEdge h4 = new HalfEdge(p4, p1);
return CompGeo.inside(h, new Point(x, y), farAway);
}

public ArrayList<HalfEdge> getAllLeaving() {
ArrayList<HalfEdge> others = getOtherLeaving();
others.add(this);
Expand Down Expand Up @@ -370,6 +412,8 @@ public class HalfEdge {
incidentFace = f;
}



public void printRNext() {
//System.out.println(" " + origin);
HalfEdge temp = next;
Expand Down
11 changes: 11 additions & 0 deletions main/PointList.pde
Expand Up @@ -51,6 +51,17 @@ public class PointList {
return struct;
}

public HalfEdge getHalfEdgeBySinglePoint(float x, float y, float distance) {
ArrayList<HalfEdge> pieces = getAllStructures();
int num = pieces.size();
HalfEdge temp = null;
for (int i = 0; i < num; i++) {
temp = pieces.get(i).findStart(x,y,distance, far);
if (temp != null) { return temp; }
}
return null;
}

public HalfEdge getHalfEdge(Point p, Point q) {
//System.out.println(p);
//System.out.println(q);
Expand Down

0 comments on commit 284754e

Please sign in to comment.