Menu

#823 Determining when an arc forms a full circle in do_arc()

Version 5
closed-accepted
nobody
None
5
2025-04-09
2025-04-06
No

When drawing a circle using "with circles" or "object circle" with arc_start : arc_end, the result may not always be what you expect. Depending on the values arc_start, arc_end provided, the arc may not be drawn at all. Consider the following examples:

    No. start : end  result
    ------------------------------
    1       0 : 360  full circle
    2      10 : 370  nothing is drawn
    3     360 : 720  nothing is drawn
    4    -180 : 180  nothing is drawn
    5    -360 : 0    nothing is drawn
    6     360 : 0    nothing is drawn
    7       0 :-360  nothing is drawn
  • Case 1 is straightforward: a full circle is drawn.
  • Cases 2 to 5 intuitively should also form a full circle, but they do not.
  • Cases 6 and 7 reinterpret the given angles within the range [0:360] and draw arcs counterclockwise, which should also result in a full circle.

Additionally, the current implementation considers an arc to be a full circle if the difference between start and end is very close to a multiple of 360 (within 0.1 degrees). However, this behavior is not clearly explained in the documentation, making it difficult for users to predict.

    No. start : end  result
    ------------------------------
    8     0.1 : 360   full circle 
    9     0.2 : 360   arc
    10    0.0 : 359.9 full circle 
    11    0.0 : 359.8 arc
    12  180.1 : 540.0 full circle 
    13  180.2 : 540.0 arc
    No. start : end  result
    ------------------------------
    14    0.0 : 0.1   full circle
    15    0.0 : 0.2   arc
    16   90.0 : 90.1  full circle
    17   90.0 : 90.2  arc
    18  -90.1 : -90   arc ?
    19  -90.2 : -90   arc

Proposed Fix

I propose a clearer and more intuitive rule for determining when a full circle should be drawn:

  1. If start and end are exactly the same, draw nothing.
  2. If the difference between start and end is an exact multiple of 360, draw a full circle. Otherwise, draw an arc.

Under this rule:

  • Cases 2 to 7 would correctly be recognized as full circles.
  • Cases 8 to 11 would be treated as arcs.
  • Cases 14 to 19 would be treated as arcs.

This approach makes the behavior of do_arc() more predictable and aligns better with user expectations.

Patch file: gnuplot_arc_full_circle.patch

Sample script: example.gp

2 Attachments

Discussion

  • Hiroki Motoyoshi

    I'm sorry.
    Correction to the third table.

        No. start : end  result
        ------------------------------
        14    0.0 : 0.1   nothing is drawn
        15    0.0 : 0.2   arc
        16   90.0 : 90.1  nothing is drawn
        17   90.0 : 90.2  arc
        18  -90.1 : -90   arc ?
        19  -90.2 : -90   arc
    
     
  • Ethan Merritt

    Ethan Merritt - 2025-04-09
    • status: open --> closed-accepted
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.