[PATCH] [cairo-path-stroke] Correct the mitre limit derivation.

Chris Wilson chris at chris-wilson.co.uk
Wed Sep 26 03:33:10 PDT 2007


The first identity used in the derivation of the mitre limit is
incorrect, namely secant(psi/2) ≠ 1/sin(psi/2) but
secant(psi/2) = 1/cos(psi/2) instead. Update the derivation using the
identity 2·cos²(psi/2) = 1+cos(psi) and arrive at the similar result
2 <= ml² (1 + in · out).

(Fixes https://bugs.freedesktop.org/show_bug.cgi?id=7245.)
---
 src/cairo-path-stroke.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index d8d989b..1feda9d 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -284,13 +284,13 @@ _cairo_stroker_join (cairo_stroker_t *stroker, cairo_stroke_face_t *in, cairo_st
 	 *
 	 * where psi is the angle between in and out
 	 *
-	 *				secant(psi/2) = 1/sin(psi/2)
-	 *	1/sin(psi/2) <= ml
-	 *	1 <= ml sin(psi/2)
-	 *	1 <= ml² sin²(psi/2)
-	 *	2 <= ml² 2 sin²(psi/2)
-	 *				2·sin²(psi/2) = 1-cos(psi)
-	 *	2 <= ml² (1-cos(psi))
+	 *				secant(psi/2) = 1/cos(psi/2)
+	 *	1/cos(psi/2) <= ml
+	 *	1 <= ml cos(psi/2)
+	 *	1 <= ml² cos²(psi/2)
+	 *	2 <= ml² 2 cos²(psi/2)
+	 *				2·cos²(psi/2) = 1+cos(psi)
+	 *	2 <= ml² (1+cos(psi))
 	 *
 	 *				in · out = |in| |out| cos (psi)
 	 *
@@ -298,10 +298,10 @@ _cairo_stroker_join (cairo_stroker_t *stroker, cairo_stroke_face_t *in, cairo_st
 	 *
 	 *				in · out = cos (psi)
 	 *
-	 *	2 <= ml² (1 - in · out)
+	 *	2 <= ml² (1 + in · out)
 	 *
 	 */
-	if (2 <= ml * ml * (1 - in_dot_out)) {
+	if (2 <= ml * ml * (1 + in_dot_out)) {
 	    double		x1, y1, x2, y2;
 	    double		mx, my;
 	    double		dx1, dx2, dy1, dy2;
-- 
1.5.2.5


--fd5uyaI9j6xoeUBo--


More information about the cairo mailing list