From 470cf627a41481082872f46154d8086192a43cbf Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Sat, 4 Jul 2009 21:16:31 +0200 Subject: [PATCH] [AdgPath] Using a proper approach to check a joint for convexity The previous algorithm was more a placeholder than a solution. The actual algorithm does the job but uses trygonometry to get the result: probably there is a better solution. --- adg/adg-path.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/adg/adg-path.c b/adg/adg-path.c index e16a4443..a78a5cd0 100644 --- a/adg/adg-path.c +++ b/adg/adg-path.c @@ -1069,10 +1069,17 @@ static gboolean is_convex(const CpmlPrimitive *primitive1, const CpmlPrimitive *primitive2) { CpmlVector v1, v2; + gdouble angle1, angle2; cpml_primitive_vector_at(primitive1, &v1, -1); cpml_primitive_vector_at(primitive2, &v2, 0); - /* I think this is a naive (and wrong) approach: test case needed */ - return cpml_vector_angle(&v1) > cpml_vector_angle(&v2); + /* Probably there is a smarter way to get this without trygonometry */ + angle1 = cpml_vector_angle(&v1); + angle2 = cpml_vector_angle(&v2); + + if (angle1 > angle2) + angle1 -= M_PI*2; + + return angle2-angle1 > M_PI; } -- 2.11.4.GIT