summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f1c965f)
raw | patch | inline | side by side (parent: f1c965f)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 6 Feb 2008 06:28:10 +0000 (06:28 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 6 Feb 2008 06:28:10 +0000 (06:28 +0000) |
src/sp-shape.cpp | patch | blob | history |
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 4b27ef8ba870c289e763bcc0481db13fd0bafc43..d1f6d78867e73b04750b26bb68e15b97d3402ba0 100644 (file)
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
* http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
*/
-static double const no_tangent = 128.0; /* arbitrarily-chosen value outside the range of atan2, i.e. outside of [-pi, pi]. */
+static double const no_tangent = 128.0; /* arbitrarily-chosen value outside the range of atan2,
+ * i.e. outside of [-pi, pi]. This value is incremented by
+ * 1 and checked using > to be safe from floating-point
+ * equality comparison madness.*/
/**
* Helper function to calculate the outgoing tangent of a path
if (bp == bp0) {
/* Gone right around the subpath without finding any different point since the
* initial moveto. */
- return no_tangent;
+ return no_tangent + 1;
}
if (bp->code != NR_MOVETO) {
/* Open subpath. */
- return no_tangent;
+ return no_tangent + 1;
}
other = bp->c(3);
if (other != p0) {
if (bp == bp0) {
/* Back where we started, so zero-length subpath. */
- return no_tangent;
+ return no_tangent + 1;
/* Note: this test must come after we've looked at element bp, in case bp0 is a curve:
* we must look at c(1) and c(2). (E.g. single-curve subpath.)
}
if (bp->code != NR_MOVETO) {
/* Open subpath. */
- return no_tangent;
+ return no_tangent + 1;
}
bp = last_seg_in_subpath(bp0);
break;
default: /* includes NR_END */
g_error("Found invalid path code %u in middle of path.", bp->code);
- return no_tangent;
+ return no_tangent + 1;
}
if (bp == bp0) {
/* Back where we started from: zero-length subpath. */
- return no_tangent;
+ return no_tangent + 1;
}
}
double const angle1 = incoming_tangent(bp);
double const angle2 = outgoing_tangent(bp);
- /* angle1 and angle2 are now each either unset (i.e. still 100 from their initialization) or in
- [-pi, pi] from atan2. */
- g_assert((-3.15 < angle1 && angle1 < 3.15) || (angle1 == no_tangent));
- g_assert((-3.15 < angle2 && angle2 < 3.15) || (angle2 == no_tangent));
-
double ret_angle;
- if (angle1 == no_tangent) {
+ if (angle1 > no_tangent) {
/* First vertex of an open subpath. */
- ret_angle = ( angle2 == no_tangent
+ ret_angle = ( angle2 > no_tangent
? 0.
: angle2 );
- } else if (angle2 == no_tangent) {
+ } else if (angle2 > no_tangent) {
/* Last vertex of an open subpath. */
ret_angle = angle1;
} else {