summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Muizelaar <jmuizelaar@mozilla.com>2009-09-18 12:17:46 -0400
committerJeff Muizelaar <jmuizelaar@mozilla.com>2009-09-18 12:17:46 -0400
commit531e8045980c966b8e51df933721f9b86c6b1539 (patch)
treecb9595ce2d1d9c2b9276462231387b397a9f308d
parentf4336352405ee7c184d45a73cdd6c1a0526843db (diff)
Add a description of how we compute the spline_error_squared.
-rw-r--r--src/cairo-spline.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/cairo-spline.c b/src/cairo-spline.c
index 780c21fe..639d9bdb 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);