[cairo-commit] src/cairo-spline.c
Jeff Muizelaar
jrmuizel at kemper.freedesktop.org
Fri Sep 18 09:20:06 PDT 2009
src/cairo-spline.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
New commits:
commit 531e8045980c966b8e51df933721f9b86c6b1539
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date: Fri Sep 18 12:17:46 2009 -0400
Add a description of how we compute the spline_error_squared.
diff --git a/src/cairo-spline.c b/src/cairo-spline.c
index 780c21f..639d9bd 100644
--- a/src/cairo-spline.c
+++ b/src/cairo-spline.c
@@ -124,12 +124,10 @@ _cairo_spline_error_squared (const cairo_spline_knots_t *knots)
double bdx, bdy, berr;
double cdx, cdy, cerr;
- /* Intersection point (px):
- * px = p1 + u(p2 - p1)
- * (p - px) â (p2 - p1) = 0
- * Thus:
- * u = ((p - p1) â (p2 - p1)) / â¥p2 - p1â¥Â²;
- */
+ /* We are going to compute the distance (squared) between each of the the b
+ * and c control points and the segment a-b. The maximum of these two
+ * distances will be our approximation error. */
+
bdx = _cairo_fixed_to_double (knots->b.x - knots->a.x);
bdy = _cairo_fixed_to_double (knots->b.y - knots->a.y);
@@ -137,6 +135,13 @@ _cairo_spline_error_squared (const cairo_spline_knots_t *knots)
cdy = _cairo_fixed_to_double (knots->c.y - knots->a.y);
if (knots->a.x != knots->d.x || knots->a.y != knots->d.y) {
+ /* Intersection point (px):
+ * px = p1 + u(p2 - p1)
+ * (p - px) â (p2 - p1) = 0
+ * Thus:
+ * u = ((p - p1) â (p2 - p1)) / â¥p2 - p1â¥Â²;
+ */
+
double dx, dy, u, v;
dx = _cairo_fixed_to_double (knots->d.x - knots->a.x);
More information about the cairo-commit
mailing list