Markers and angle bisectors
I'm still improving Inkscape's marker support, and have discovered another deficiency in the spec:
11.6.2 "the marker's positive x-axis should point toward the angle bisector for the angle at the given vertex,"
Consider the attached SVG. The black line represents a path Its end point is at the bottom left of the drawing. Confusingly, all of the markers in Inkscape are designed to point from the end of the line towards its start, a convention I've followed here. The red lines represent the inner angle bisectors. The blue lines represent markers with positive x-axis pointing towards the angle bisector.
You will notice that the two arrows point in opposite directions. This is clearly undesirable. The correct action would be to use the inner angle bisector for the leftmost marker, and the outer for the rightmost marker.
A rule which accomplishes this is: If the clockwise angle from the incoming vector to the outgoing vector is greater than 180%, use the outer angle bisector, else use the inner angle bisector. Incoming vectors are those which are closer to the start of the path.
This is the rule I intend to implement in Inkscape.
A rule which accomplishes this is: If the clockwise angle from the incoming vector to the outgoing vector is greater than 180%, use the outer angle bisector, else use the inner angle bisector. Incoming vectors are those which are closer to the start of the path.
I'm not sure I completely understand your intent. If I add mid-markers to the path in your example, they both look in one direction. I think this is both correct and logical, and Batik/Adobe render them exactly the same. So I don't think we need to change anything here.
On Fri, 2004-08-06 at 15:34, bulia byak wrote:
A rule which accomplishes this is: If the clockwise angle from the incoming vector to the outgoing vector is greater than 180%, use the outer angle bisector, else use the inner angle bisector. Incoming vectors are those which are closer to the start of the path.
I'm not sure I completely understand your intent. If I add mid-markers to the path in your example, they both look in one direction. I think this is both correct and logical, and Batik/Adobe render them exactly the same. So I don't think we need to change anything here.
Inkscape currently does the right thing sometimes (by pure luck, more or less) -- that particular example does not illustrate a flaw in Inkscape, but in the SVG spec. An example illustrating two errors in Inkscape's behavior is attached.
On the top path, it looks like the marker's direction is controlled by the wrong control point of the bezier.
The bottom two paths demonstrate that Inkscape computes angles incorrectly -- it averages the tangent vectors of the incoming and outgoing segments, rather than averaging their angles.
Inkscape currently does the right thing sometimes (by pure luck, more or less) -- that particular example does not illustrate a flaw in Inkscape, but in the SVG spec.
In that case Inkscape must stay compliant to the spec. Sorry I didn't notice at first that your previous message was directed to w3c-svg list. It's good that you make our concerns heard there. However, until the spec changes, we must only provide our extensions in a way that does not break our files in other renderers.
On the top path, it looks like the marker's direction is controlled by the wrong control point of the bezier.
The bottom two paths demonstrate that Inkscape computes angles incorrectly -- it averages the tangent vectors of the incoming and outgoing segments, rather than averaging their angles.
Yes, these are real problems that need to be fixed. Please submit a bug report (unless you plan to fix them yourself soon :)
On Fri, 2004-08-06 at 16:11, bulia byak wrote:
Inkscape currently does the right thing sometimes (by pure luck, more or less) -- that particular example does not illustrate a flaw in Inkscape, but in the SVG spec.
In that case Inkscape must stay compliant to the spec. Sorry I didn't notice at first that your previous message was directed to w3c-svg list. It's good that you make our concerns heard there. However, until the spec changes, we must only provide our extensions in a way that does not break our files in other renderers.
My work does not violate the spec. The spec leaves open which of the two angle bisectors to choose. My patch (now complete except, for two corner cases, one of which Inkscape probably mishandles anyway) chooses an angle bisector based on the rule I proposed.
If other renderers happen to always choose the inner (or outer) bisector, there's nothing we can do about that, and it's conformant to the spec as written. But as you said, the other renderers you tried have the same directionality on my first example as Inkscape does, and which my patch will preserve. So, we will be compliant with the spec and with other renderers.
My work does not violate the spec. The spec leaves open which of the two angle bisectors to choose.
Maybe the spec is not 100% clear, but I think it's natural that markers always point in the same direction _along the path_, from its start to its end. Making the marker direction depend on angle is wrong IMHO. Which bisector to choose for a node on a straight line? Will it flip when the angle goes through 180 degrees?
Anyway, I've just checked your last changes in CVS. The two problems you demonstrated before are now fixed (thanks!) and the angle-bisector.svg shows correctly (as before). However this bug is not fixed:
http://sourceforge.net/tracker/index.php?func=detail&aid=999786&grou...
and moreover, when I edit the star from the file in that bug, it crashes with:
** ERROR **: file sp-shape.cpp: line 378 (float angle_for_seg(const SPShape*, const NArtBpath*, int)): should not be reached aborting...
On Sat, Aug 07, 2004 at 12:44:01AM -0300, bulia byak wrote:
My work does not violate the spec. The spec leaves open which of the two angle bisectors to choose.
Maybe the spec is not 100% clear, but I think it's natural that markers always point in the same direction _along the path_, from its start to its end.
Or, in the case of Inkscape, from its end towards its start.
Making the marker direction depend on angle is wrong IMHO. Which bisector to choose for a node on a straight line? Will it flip when the angle goes through 180 degrees?
Anyway, I've just checked your last changes in CVS. The two problems you demonstrated before are now fixed (thanks!) and the angle-bisector.svg shows correctly (as before). However this bug is not fixed:
http://sourceforge.net/tracker/index.php?func=detail&aid=999786&grou...
and moreover, when I edit the star from the file in that bug, it crashes with:
** ERROR **: file sp-shape.cpp: line 378 (float angle_for_seg(const SPShape*, const NArtBpath*, int)): should not be reached aborting...
Yep -- I checked in the wrong version! Oops. Anyway, it should be fixed now.
-- -David Turner
http://sourceforge.net/tracker/index.php?func=detail&aid=999786&grou...
Now everything works perfectly. Thank you! I'm closing that bug.
participants (3)
-
bulia byak
-
Dave Turner
-
David Turner