|
From: Daniel J S. <dan...@ie...> - 2003-11-22 21:18:30
|
Alan, Ethan, I've drawn up a diagram illustrating the tip of an arrow and how to compensate for the line ending so that the tip lands right at the desired end point. It is in PDF format at: http://acer-access.com/~ds...@ac.../ under "gnuplot stuff". The formula is actually quite simple given the angle of the tip "wings" as specified in Gnuplot. Basically a small vector opposite the direction of the vector from start (S) to end (E) is added to the end point (E). Here is a small chunk of code that implements the formula intended for the "place_arrows" routine in graphics.c. But THIS DOESN'T WORK currently (read below) so just illustrates the simplicity of the formula. apply_head_properties(&(this_arrow->arrow_properties)); /* A correction factor for the line so that the arrow head does * not extend past the ending point of the line. * * THIS IS CURRENTLY JUST A DEMONSTRATION AND DOESN'T ACCOUNT * FOR ALL THE SPECIAL CONDITIONS LIKE headlength < 0, alpha = 0, * ETC. */ if (this_arrow->arrow_properties.head_length > DBL_EPSILON) { double dx = (double) sx - (double) ex; double dy = (double) sy - (double) ey; double len_arrow = sqrt(dx * dx + dy * dy); double alpha = this_arrow->arrow_properties.head_angle * DEG2RAD; double w = this_arrow->arrow_properties.lp_properties.l_width; double factor = w/(2*len_arrow*sin(alpha)); ex += dx*factor; ey += dy*factor; } (*t->arrow) (sx, sy, ex, ey, this_arrow->arrow_properties.head); OK. This doesn't work because THE LINE WIDTH IS NOT KNOWN IN TERMS OF PLOT UNITS. That is, in the formula above, "w" should be the line width in terms of plot units not in terms of "unity" units. You see, the line width properties are sent all the way down to the driver level and I think it is there that the value of "lp_properties.l_width" takes on a meaning. So there are a couple significant problems here in compensating for the tip of the arrow. 1) Where should the compensation for the arrow tip be done? The options are inside the Gnuplot "place_arrow" routine, inside the default terminal "do_arrow" function, or inside each individual driver's "arrow" function. There are pluses and minuses for all. 2) Somewhere the width of a line must be known in terms of plot units in order to compensate for the arrow tip. I don't see where this information can be gotten easily and this could be some major driver level coding to send back such information. (Ethan, is this similar to the problems you've come across with getting font height information back from the driver?) Dan Alan G Isaac wrote: >>On Monday 20 October 2003 23:14, Alan G Isaac wrote: >> >> >>>Basic user interface issue: >>>set arrow from ptA to ptB >>>will be expected to do precisely that: >>>start at ptA and end at ptB. >>> >>> > >On Tue, 21 Oct 2003 11:20:41 -0700 Ethan Merritt <merritt@u.washington.edu> wrote: > > >>Gnuplot does that now. What we are disagreeing about is the >>meaning of the word "precisely". >> >> > >Actually I think we are disagreeing on the more basic words >'start' and 'end'. I have not been able to understand your >apparent suggestion (?) that the user will expect ink past >ptB (in the direction of the arrow). > >On Tue, 21 Oct 2003 11:20:41 -0700 Ethan Merritt <merritt@u.washington.edu> wrote: > > >>You may not like the behavior, but that doesn't mean it >>is ambiguous. >> >> > >I think you are giving a programmer's perspective rather >than a user's perspective on ambiguity here. Of course, >the code says what it says. But a user has no simple >way to tell where an arrow will end. (I.e., where the >ink will end.) > >On Tue, 21 Oct 2003 11:20:41 -0700 Ethan Merritt <merritt@u.washington.edu> wrote: > > >>think of line segments in gnuplot as a >>connect-the-dots process: place a dot at the "from" >>position, place another at the "to" position, then connect >>them. >> >> > >I accept that if I draw several independent (i.e., unjoined) >line segments end to end that round caps will produce a >better looking line. But this is not how people use arrows. >Or rather, I don't know anyone using arrows this way. >And those who do have a round caps option available to them. > > > >>I personally think that rounded ends are best. >>But it should be left up to the user, as it is now. >> >> > >No, it isn't. Not for arrows with heads. Selecting butt >caps does not cause arrowhead ink to terminate at the >specified end point. > > > > >>But they don't. They extend exactly to the specified >>endpoint *** to the resolution of the pen used ***. >> >> > > > >>>What is more, with >>>this behavior it is essentially impossible for me to make an >>>arrow terminate precisely where I wish it to. >>> >>> > > > >>I don't see why. Can't you just specifiy a very thin >>pen width and a filled arrowhead? Stroke the tail of >>the arrow separately if you want that part thicker. >> >> > >Stroke the tail to where, exactly? (That is the >user interface issue!) > >A picture is worth a thousand words. How can the sript >below be considered to produce desirable output for these >script commands? I still say the key issue is: what will >users expect, and what makes it easiest for them to achieve >precisely what they desire in a predictable fashion? When >the user wants an arrow from ptA to ptB, that really ends at >ptB (i.e., no ink past ptB), s/he should not have to make >length adjustments everytime s/he changes the linewidth or >arrowhead angle. Yet that is the current situation. I >cannot see that this behavior (in the sample script) can >meet the goal of being predictable for the user. And I add >to that a personal query: thinking back over your own use of >arrows in gnuplot, can you really claim that your *intent* >when you first think of drawing an arrow from ptA to ptB >is for the ink to extend past ptB? > >Alan Isaac > >############################################################## >set term post eps color solid butt >set output 'c:\temp3.eps' >set xrange [0:4] >set yrange [0:5] >set style arrow 1 front head size 0.2,15 nofilled lt -1 >set style arrow 2 front nohead lt -1 >set style arrow 3 front nohead lw 5 lt -1 >set style arrow 4 front head size 0.2,15 nofilled lw 5 lt -1 >set arrow from 1,1 to 3,1 as 1 >set arrow from 1,2 to 3,2 as 2 >set arrow from 1,3 to 3,3 as 3 >set arrow from 1,4 to 3,4 as 4 >plot '-' with points ps 1 pt 7 lt 1 >3 1 >3 2 >3 3 >e >############################################################## > > > > > >------------------------------------------------------- >This SF.net email is sponsored by OSDN developer relations >Here's your chance to show off your extensive product knowledge >We want to know what you know. Tell us and you have a chance to win $100 >http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54 >_______________________________________________ >gnuplot-beta mailing list >gnu...@li... >https://lists.sourceforge.net/lists/listinfo/gnuplot-beta > > > > -- Dan Sebald email: daniel . sebald @ ie ee . o rg URL: ht tp://acer-access.c om/~dsebald @ acer-access.c om/ |