Browse Source

* 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
remotes/tiles
sam 16 years ago
parent
commit
585af308a2
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      examples/img2rubik.c

+ 4
- 3
examples/img2rubik.c View File

@@ -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]);


Loading…
Cancel
Save