| Summary: | [GEF4] Point.getConvexHull returns different results on JDK 6 and 7 | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Fabian Steeg <steeg> |
| Component: | GEF Geometry | Assignee: | Matthias Wienand <matthias.wienand> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | matthias.wienand |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| Whiteboard: | |||
|
Description
Fabian Steeg
The sorting algorithm used by Arrays.sort() changed from JDK 6 to 7 (and uses less compares). I do not know yet why that change affects the Point.getConvexHull() method. Obviously, the code should work with any sorting algorithm. The code uses the Vector.getAngleCCW() method to sort the points. Later on, when the convex hull is build up, Straight.getSignedDistanceCCW() is used to test if three consecutive points form a "left turn" or a "right turn". I think those two methods disagree in some degenerate cases (like the failing test case). If that is the case, a simple fix would be to make use of one of those methods to implement the other. Another note: The comparator used to sort the points currently never returns 0. As the Arrays.sort() method is specified to use a stable sorting algorithm, maybe the comparator should return 0 if the arrangement of two points does not matter, so that, if the sort algorithm changes, the outcome would still be exactly the same. I cherry-picked your commit now. Thank you for the help! I fixed the inconsistency by exclusively using the Straight#getSignedDistanceCCW() method instead of the Vector#getAngleCCW() method. |