-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
JimmyBoivie
authored and
JimmyBoivie
committed
Dec 5, 2015
1 parent
86670ff
commit 130e197
Showing
3 changed files
with
114 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
public static class CompGeo { | ||
|
||
public int CCW(Point a, Point b, Point c) { | ||
public static 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(Point parent, Point child, Point v1, Point v2) { | ||
public static 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); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters