From a83af6c9ed35849821f85267c7e9670ec87ad834 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 10 May 2015 16:28:23 +0200 Subject: Refactor det_matrix --- flam3.c | 18 ++++++------------ interpolation.c | 4 ---- interpolation.h | 1 - 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/flam3.c b/flam3.c index 74decee..22f526a 100644 --- a/flam3.c +++ b/flam3.c @@ -1242,23 +1242,17 @@ static double round6(double x) { return 1e-6*(int)(x+0.5); } +static double det_matrix(double2 m[3]) { + return m[0][0] * m[1][1] - m[0][1] * m[1][0]; +} + static int compare_xforms(const void *av, const void *bv) { flam3_xform *a = (flam3_xform *) av; flam3_xform *b = (flam3_xform *) bv; - double aa[2][2]; - double bb[2][2]; double ad, bd; - aa[0][0] = a->c[0][0]; - aa[0][1] = a->c[0][1]; - aa[1][0] = a->c[1][0]; - aa[1][1] = a->c[1][1]; - bb[0][0] = b->c[0][0]; - bb[0][1] = b->c[0][1]; - bb[1][0] = b->c[1][0]; - bb[1][1] = b->c[1][1]; - ad = det_matrix(aa); - bd = det_matrix(bb); + ad = det_matrix(a->c); + bd = det_matrix(b->c); if (a->color_speed > b->color_speed) return 1; if (a->color_speed < b->color_speed) return -1; diff --git a/interpolation.c b/interpolation.c index 0f42c8c..c2b245c 100644 --- a/interpolation.c +++ b/interpolation.c @@ -27,10 +27,6 @@ for (k = 0; k < ncp; k++) tt += c[k] * cpi[k].x; \ result->x = (int)rint(tt); } while(0) -double det_matrix(double s[2][2]) { - return s[0][0] * s[1][1] - s[0][1] * s[1][0]; -} - int id_matrix(double2 s[3]) { return (s[0][0] == 1.0) && diff --git a/interpolation.h b/interpolation.h index 747d029..0f626ef 100644 --- a/interpolation.h +++ b/interpolation.h @@ -21,7 +21,6 @@ #include "flam3.h" int id_matrix(double2 s[3]); -double det_matrix(double s[2][2]); #if 0 void interpolate_cmap(flam3_palette cmap, double blend, -- cgit v1.2.3