[gs-cvs] rev 7026 - trunk/gs/src
dan at ghostscript.com
dan at ghostscript.com
Fri Sep 8 10:14:11 PDT 2006
Author: dan
Date: 2006-09-08 10:14:10 -0700 (Fri, 08 Sep 2006)
New Revision: 7026
Modified:
trunk/gs/src/gscoord.c
trunk/gs/src/gsmatrix.c
Log:
Fix for matrix operation floating point accuracy differences in the
CET 10-xx.ps files.
DETAILS:
This fix adds casts to float to produce the same floating point results
from matrix calculations as expected by the CET.
Modified: trunk/gs/src/gscoord.c
===================================================================
--- trunk/gs/src/gscoord.c 2006-09-07 11:59:03 UTC (rev 7025)
+++ trunk/gs/src/gscoord.c 2006-09-08 17:14:10 UTC (rev 7026)
@@ -27,7 +27,7 @@
#include "gxdevice.h"
/* Choose whether to enable the rounding code in update_ctm. */
-#define ROUND_CTM_FIXED 1
+#define ROUND_CTM_FIXED 0
/* Forward declarations */
#ifdef DEBUG
@@ -229,8 +229,8 @@
if ((code = gs_distance_transform(dx, dy, &ctm_only(pgs), &pt)) < 0)
return code;
- pt.x += pgs->ctm.tx;
- pt.y += pgs->ctm.ty;
+ pt.x = (float)pt.x + pgs->ctm.tx;
+ pt.y = (float)pt.y + pgs->ctm.ty;
update_ctm(pgs, pt.x, pt.y);
#ifdef DEBUG
if (gs_debug_c('x'))
Modified: trunk/gs/src/gsmatrix.c
===================================================================
--- trunk/gs/src/gsmatrix.c 2006-09-07 11:59:03 UTC (rev 7025)
+++ trunk/gs/src/gsmatrix.c 2006-09-08 17:14:10 UTC (rev 7026)
@@ -124,17 +124,22 @@
pmr->yx = 0.0;
pmr->ty = -(pmr->yy = 1.0 / pm->yy) * pm->ty;
} else {
- double det = pm->xx * pm->yy - pm->xy * pm->yx;
- double mxx = pm->xx, mtx = pm->tx;
+ float mxx = pm->xx, myy = pm->yy, mxy = pm->xy, myx = pm->yx;
+ float mtx = pm->tx, mty = pm->ty;
+ float det = (float)(mxx * myy) - (float)(mxy * myx);
+ /*
+ * We are doing the math as floats instead of doubles to reproduce
+ * the results in page 1 of CET 10-09.ps
+ */
if (det == 0)
return_error(gs_error_undefinedresult);
- pmr->xx = pm->yy / det;
- pmr->xy = -pm->xy / det;
- pmr->yx = -pm->yx / det;
- pmr->yy = mxx / det; /* xx is already changed */
- pmr->tx = -(mtx * pmr->xx + pm->ty * pmr->yx);
- pmr->ty = -(mtx * pmr->xy + pm->ty * pmr->yy); /* tx ditto */
+ pmr->xx = myy / det;
+ pmr->xy = -mxy / det;
+ pmr->yx = -myx / det;
+ pmr->yy = mxx / det;
+ pmr->tx = (((float)(mty * myx) - (float)(mtx * myy))) / det;
+ pmr->ty = (((float)(mtx * mxy) - (float)(mty * mxx))) / det;
}
return 0;
}
@@ -200,12 +205,16 @@
gs_point_transform(floatp x, floatp y, const gs_matrix * pmat,
gs_point * ppt)
{
- ppt->x = x * pmat->xx + pmat->tx;
- ppt->y = y * pmat->yy + pmat->ty;
+ /*
+ * The float casts are there to reproduce results in CET 10-01.ps
+ * page 4.
+ */
+ ppt->x = (float)(x * pmat->xx) + pmat->tx;
+ ppt->y = (float)(y * pmat->yy) + pmat->ty;
if (!is_fzero(pmat->yx))
- ppt->x += y * pmat->yx;
+ ppt->x += (float)(y * pmat->yx);
if (!is_fzero(pmat->xy))
- ppt->y += x * pmat->xy;
+ ppt->y += (float)(x * pmat->xy);
return 0;
}
More information about the gs-cvs
mailing list