From 585af308a21a5fab0700c4c64e06d47e7ade5fe2 Mon Sep 17 00:00:00 2001 From: sam Date: Sat, 16 Aug 2008 13:16:13 +0000 Subject: [PATCH] * img2rubik.c: fix convex hull build, some points were not properly excluded. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2733 92316355-f0b4-4df1-b90c-862c8a59935f --- examples/img2rubik.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/img2rubik.c b/examples/img2rubik.c index de7a053..12a15d1 100644 --- a/examples/img2rubik.c +++ b/examples/img2rubik.c @@ -21,7 +21,7 @@ #define BRIGHT(x) (0.299*(x)[0] + 0.587*(x)[1] + 0.114*(x)[2]) #define MAXCOLORS 16 -#define STEPS 25 +#define STEPS 256 #define EPSILON (0.000001) typedef struct @@ -213,9 +213,9 @@ static hull_t *compute_hull(int ncolors, double const *palette) * (pts[j + 1][Y] - pts[0][Y]); double k2 = (pts[j + 1][X] - pts[0][X]) * (pts[j][Y] - pts[0][Y]); - if(k1 < k2) + if(k1 < k2 - EPSILON) SWAP(pts[j], pts[j + 1]); - else if(k1 == k2) + else if(k1 < k2 + EPSILON) { /* Aligned! keep the farthest point */ double ax = pts[j][X] - pts[0][X]; @@ -250,6 +250,7 @@ static hull_t *compute_hull(int ncolors, double const *palette) else i++; } + /* FIXME: check the last point */ for(i = 0; i < npts; i++) debug(" 2D pt[%i] (%g,%g)\n", i, pts[i][X], pts[i][Y]);