#679 arc direction patch

Version 5
open
nobody
None
5
2014-05-03
2014-05-02
Shigeharu TAKENO
No

The current gnuplot draws arc only counterclockwise direction (do_arc()
in term.c). So, if arc_start = 90 and arc_end = 80, draw arc with 350
angle, not 10 angle.

Ithink the algorithm of the attached patch for src/term.c 1.291 is more
reasonable:
a) if arc_start > arc_end, swap these two angles,
b) if arc_end > arc_start + 360, reset to arc_start = 0 and arc_end = 360.

Using this patch, we can draw a clockwise pi chart as following:

set xrange [-10:10]
set style fill transparent solid 0.9 noborder

percent to arc

cmth(x) = 450 - x*3.6
R = 5
cmp = 0 # cumulative percent
plot '-' using (0):(0):(R):(cmth(cmp)):(cmp=cmp+$1,cmth(cmp)):0 \ with circles lc var
40
30
15
10
5
e

1 Attachments

Discussion

  • Ethan Merritt
    Ethan Merritt
    2014-05-02

    That change would make it impossible to draw a shape such as this one:

      set object  1 circle center 0, 0, 0 size 0.5 arc [30:10]
      set object  1 fill solid fillcolor rgb "blue"
    
     
    Attachments
  • I think to draw such image, we should specify angles from 30 to 370, not to 10.

     
  • Ethan Merritt
    Ethan Merritt
    2014-05-03

    The usual conventions are that angles are limited either to [0:360] or [-180:180]. Requiring to specify an endpoint of 370 violates both of these conventions.

    What is the disadvantage of always proceeding counterclockwise?