Talk:Convex hull: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 78: | Line 78: | ||
} |
} |
||
Last error |
|||
int comp(const void *lhs, const void *rhs) { |
|||
Point lp = *((Point *)lhs); |
|||
Point rp = *((Point *)rhs); |
|||
if (lp.x < rp.x) return -1; |
|||
if (rp.x < lp.x) return 1; |
|||
return 0; |
|||
} |
|||
It should be |
|||
int comp(const void* lhs, const void* rhs) { |
|||
Point lp = *((Point*)lhs); |
|||
Point rp = *((Point*)rhs); |
|||
if (lp.x < rp.x) return -1; |
|||
if (rp.x < lp.x) return 1; |
|||
return rp.y - lp.y ; |
|||
} |
|||
: You should test the code, and think about the results here. For example, "ccw" is a routine which determines whether the winding is clockwise or counterclockwise. But from which side? Anyways... since that's not a documented issue... ccw should work regardless of the winding direction -- as long as the winding direction is consistent. So... you have encountered a real issue here. But it's probably not a code correctness issue -- it's probably a lack of adequate documentation issue (which is a frequent problem for coders). |
: You should test the code, and think about the results here. For example, "ccw" is a routine which determines whether the winding is clockwise or counterclockwise. But from which side? Anyways... since that's not a documented issue... ccw should work regardless of the winding direction -- as long as the winding direction is consistent. So... you have encountered a real issue here. But it's probably not a code correctness issue -- it's probably a lack of adequate documentation issue (which is a frequent problem for coders). |