From 6bc6fbc4e85984fbd471e0410ac0fcbbddbb49c4 Mon Sep 17 00:00:00 2001 From: kramm Date: Fri, 8 Oct 2004 11:21:23 +0000 Subject: [PATCH] added another method for spline-approximation error-estimation. --- lib/drawer.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/drawer.c b/lib/drawer.c index 3ff0299..1b4f7e9 100644 --- a/lib/drawer.c +++ b/lib/drawer.c @@ -168,6 +168,7 @@ static int approximate3(const struct cspline*s, struct qspline*q, int size, doub char left = 0,recurse=0; int t; int probes = 15; + double dx,dy; /* create simple approximation: a qspline which run's through the qspline point at 0.5 */ @@ -202,8 +203,9 @@ static int approximate3(const struct cspline*s, struct qspline*q, int size, doub test.control.y += test.end.y; } +#define PROBES +#ifdef PROBES /* measure the spline's accurancy, by taking a number of probes */ - for(t=0;tend.x - s->control2.x*3 + s->control1.x*3 - s->start.x; + dy= s->end.y - s->control2.y*3 + s->control1.y*3 - s->start.y; + + /* use the integral over (f(x)-g(x))^2 between 0 and 1 + to measure the approximation quality. + (it boils down to const*d^2) + */ + recurse = (dx*dx + dy*dy > quality2); +#endif if(recurse && istep>1 && size-level > num) { istep >>= 1; -- 1.7.10.4