diff options
Diffstat (limited to 'source/fitz/geometry.c')
-rw-r--r-- | source/fitz/geometry.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/source/fitz/geometry.c b/source/fitz/geometry.c index b6b6533e..073536ff 100644 --- a/source/fitz/geometry.c +++ b/source/fitz/geometry.c @@ -217,18 +217,26 @@ int fz_try_invert_matrix(fz_matrix *dst, const fz_matrix *src) { /* Be careful to cope with dst == src */ - float a = src->a; - float det = a * src->d - src->b * src->c; - if (det >= -FLT_EPSILON && det <= FLT_EPSILON) + double sa = (double)src->a; + double sb = (double)src->b; + double sc = (double)src->c; + double sd = (double)src->d; + double da, db, dc, dd; + double det = sa * sd - sb * sc; + if (det >= -DBL_EPSILON && det <= DBL_EPSILON) return 1; det = 1 / det; - dst->a = src->d * det; - dst->b = -src->b * det; - dst->c = -src->c * det; - dst->d = a * det; - a = -src->e * dst->a - src->f * dst->c; - dst->f = -src->e * dst->b - src->f * dst->d; - dst->e = a; + da = sd * det; + dst->a = (float)da; + db = -sb * det; + dst->b = (float)db; + dc = -sc * det; + dst->c = (float)dc; + dd = sa * det; + dst->d = (float)dd; + da = -src->e * da - src->f * dc; + dst->f = (float)(-src->e * db - src->f * dd); + dst->e = (float)da; return 0; } |