summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-07-15 22:30:15 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-07-15 22:30:15 +0000
commit5896ac4906e3aa17a0500ebfcd68e3914db2fcc1 (patch)
tree98c8aa73893e8072e5c376dfba5720780c0f81d7 /src
parentadded Ruler LPE to the list of translatables (diff)
downloadinkscape-5896ac4906e3aa17a0500ebfcd68e3914db2fcc1.tar.gz
inkscape-5896ac4906e3aa17a0500ebfcd68e3914db2fcc1.zip
try to make more robust geom-nodetype. still it can give wrong types. (best tested with lpe-spiro after next svncommit, change the smoothness/cusp at the closing endpoint)
(bzr r6326)
Diffstat (limited to 'src')
-rw-r--r--src/helper/geom-nodetype.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/helper/geom-nodetype.cpp b/src/helper/geom-nodetype.cpp
index 1983fd42c..b1e427693 100644
--- a/src/helper/geom-nodetype.cpp
+++ b/src/helper/geom-nodetype.cpp
@@ -15,6 +15,7 @@
#include <2geom/curve.h>
#include <2geom/point.h>
+#include <glib.h>
#include <vector>
namespace Geom {
@@ -43,11 +44,11 @@ NodeType get_nodetype(Curve const &c_incoming, Curve const &c_outgoing)
// Determine lowest derivative that is non-zero
int n1 = 1;
- while ( (deriv1[n1] == Point(0,0)) && (n1 <= 3) ) {
+ while ( (deriv1[n1] == Point(0.,0.)) && (n1 <= 3) ) {
n1++;
}
int n2 = 1;
- while ( (deriv2[n2] == Point(0,0)) && (n2 <= 3) ) {
+ while ( (deriv2[n2] == Point(0.,0.)) && (n2 <= 3) ) {
n2++;
}
@@ -59,12 +60,17 @@ NodeType get_nodetype(Curve const &c_incoming, Curve const &c_outgoing)
return NODE_SMOOTH;
}
- if ( are_near( Geom::cross(deriv1[n1], deriv2[n2]), 0) && (Geom::dot(-deriv1[n1], deriv2[n2]) > 0) ) {
- // Apparently, the derivatives are colinear and in same direction but does the order of the derivatives match?
- if (n1 != n2)
- return NODE_SMOOTH;
- else
+ // get unit derivatives, so the errors do not depend on absolute lengths of derivatives
+ Geom::Point const d1 = - deriv1[n1] / deriv1[n1].length(); // reverse sign because it is taken in "wrong direction"
+ Geom::Point const d2 = deriv2[n2] / deriv2[n2].length();
+
+ double crossproduct = Geom::cross(d1, d2);
+ if ( are_near( crossproduct , 0.) && (Geom::dot(d1, d2) > 0.) ) {
+ // Apparently, the derivatives are colinear and in same direction but do they match exactly?
+ if ( (n1 == n2) && (Geom::are_near(-deriv1[n1], deriv2[n2])) )
return NODE_SYMM;
+ else
+ return NODE_SMOOTH;
}
return NODE_CUSP;