G2/G3 arcs with R parameter traverse the longer of the two arcs

The G2/G3 arc command can be specified using either the R parameter to describe the radius or the I/J parameter to describe the center of the arc.
If using the R parameter, unless you describe an arc of exactly 180 degrees, there are exactly 2 arcs which can fit the description, one goes through an angle under 180 degrees and one goes through an angle under 180 degrees. Both clockwise. (Counterclockwise arcs suffer the same issue, of course.)
For example, moving between the two white circles (left to right) here spaced 10 units apart with a counterclockwise arc of radius 7.07, one can construct the shorter (red) arc which traverses 90 degrees or the longer (blue) arc which traverses 270 degrees. Both have the same radius, both start and end at the right points.
It appears as though RRF always chooses the longer of the two arcs. At least it does on my machine for the path I just constructed. I would have expected the shorter, since now it appears there is no way to traverse an arc under 180 degrees.
Is this the intended behavior? It seems like one should never use the R parameter for arcs given this ambiguity and use the (overconstrained) I/J parameters instead. Perhaps there should be another parameter which specifies which of the two arcs to traverse? Or perhaps just use the shorter of the two arcs?
The Marlin firmware doesn't define the behavior either, but their example has an arc of 90 degrees. I don't have a printer with Marlin on it anymore to test.
FIRMWARE_NAME: RepRapFirmware for Duet 3 MB6HC FIRMWARE_VERSION: 3.1.1 ELECTRONICS: Duet 3 MB6HC v1.01 or later FIRMWARE_DATE: 20200519b2

It appears in CNC a negative R value will correspond to the arc over 180 degrees and a positive one will correspond to the arc under 180 degrees. Seems reasonable.
https://www.cnccookbook.com/cncgcodearccircleg02g03/
In RRF, for my path, a negative R value has the same effect as a positive R value.
G0 X20 Y0 Z10 F6000 G2 X0 Y20 R20 G2 X20 Y0 R20 G2 X0 Y20 R20 G2 X20 Y0 R20

@TDK in your code snippet there, you show the X and Y values being negated, but not the R values. I assume you tested this properly but simply made an error in typing the post?

@bot Not a typo, just showing the path I'm using. I don't think RRF claims to support negative radii parameters in any capacity, but that's tangential to the original post.
For clarity, the following two paths produce the same motion on my machine:
G0 X20 Y0 Z10 F6000 G2 X0 Y20 R20 G2 X20 Y0 R20 G2 X0 Y20 R20 G2 X20 Y0 R20
G0 X20 Y0 Z10 F6000 G2 X0 Y20 R20 G2 X20 Y0 R20 G2 X0 Y20 R20 G2 X20 Y0 R20

Gotcha, sorry for the added confusion lol.

Thanks for reporting this. I will see if it can be fixed in the next 3.2 beta release.

I've just spent a couple of very frustrating days trying to print short arcs with G2 and G3, only to find this thread. Always check the forum!
The problem is not just when the r parameter is being used. Even with I and J I cannot achieve an arc of less than 180 degrees.
It took me so long because I thought I was chasing a bug in my own code (a flaw in my understanding), but now it seems that its firmware. Grrrr.

@MJLew said in G2/G3 arcs with R parameter traverse the longer of the two arcs:
The problem is not just when the r parameter is being used. Even with I and J I cannot achieve an arc of less than 180 degrees.
Please explain. It certainly used to be possible to draw short arcs using the I and J parameters and no R parameter.

@MJLew said in G2/G3 arcs with R parameter traverse the longer of the two arcs:
The problem is not just when the r parameter is being used. Even with I and J I cannot achieve an arc of less than 180 degrees.
I can't reproduce this. The following moves through four 90 degree segments of a circle with radius 20 without issue:
G0 X20 Y0 Z10 G2 I20 J0 X0 Y20 G2 I0 J20 X20 Y0 G2 I20 J0 X0 Y20 G2 I0 J20 X20 Y0

My test files attempt to print a cylinder centred at Xc=50, Yc=50 with eight segments in each rotation. I tried using G2 and with G3 and for "method 1" I set the I and J parameters to the i=Xcx and j=Ycy (where x and y are the current x and y values), and for "method 2" I set i=xXc and j=yYc.
Total of four tries and no cylinders. With G2 method 1 I got an attractive floret like the arrangement of sunflower seeds, with G2 method 2 I got a fluted cylinder, with G3 method 1 I got a fluted cylinder with smaller flutes, and with G3 method 2 I got a flower. (Picture of prints below.)
G2 method 1.gcode:G90; absolute positioning M83; extuder to relative G1 X100 E10 G1 X55 Y50 Z0 ;loops with i=xcx and j=ycy G2 X53.535534 Y53.535534 Z0.03125 E0.327 I3.535534 J3.535534 F600 G2 X50 Y55 Z0.0625 E0.327 I0 J5 F600 G2 X46.464466 Y53.535534 Z0.09375 E0.327 I3.535534 J3.535534 F600 G2 X45 Y50 Z0.125 E0.327 I5 J0 F600 G2 X46.464466 Y46.464466 Z0.15625 E0.327 I3.535534 J3.535534 F600 G2 X50 Y45 Z0.1875 E0.327 I0 J5 F600 G2 X53.535534 Y46.464466 Z0.21875 E0.327 I3.535534 J3.535534 F600 G2 X55 Y50 Z0.25 E0.327 I5 J0 F600 G2 X53.535534 Y53.535534 Z0.28125 E0.327 I3.535534 J3.535534 F600 G2 X50 Y55 Z0.3125 E0.327 I0 J5 F600 G2 X46.464466 Y53.535534 Z0.34375 E0.327 I3.535534 J3.535534 F600 G2 X45 Y50 Z0.375 E0.327 I5 J0 F600 G2 X46.464466 Y46.464466 Z0.40625 E0.327 I3.535534 J3.535534 F600 G2 X50 Y45 Z0.4375 E0.327 I0 J5 F600 G2 X53.535534 Y46.464466 Z0.46875 E0.327 I3.535534 J3.535534 F600 G2 X55 Y50 Z0.5 E0.327 I5 J0 F600 G2 X53.535534 Y53.535534 Z0.53125 E0.327 I3.535534 J3.535534 F600 G2 X50 Y55 Z0.5625 E0.327 I0 J5 F600 G2 X46.464466 Y53.535534 Z0.59375 E0.327 I3.535534 J3.535534 F600 G2 X45 Y50 Z0.625 E0.327 I5 J0 F600 G2 X46.464466 Y46.464466 Z0.65625 E0.327 I3.535534 J3.535534 F600 G2 X50 Y45 Z0.6875 E0.327 I0 J5 F600 G2 X53.535534 Y46.464466 Z0.71875 E0.327 I3.535534 J3.535534 F600 G2 X55 Y50 Z0.75 E0.327 I5 J0 F600 G2 X53.535534 Y53.535534 Z0.78125 E0.327 I3.535534 J3.535534 F600 G2 X50 Y55 Z0.8125 E0.327 I0 J5 F600 G2 X46.464466 Y53.535534 Z0.84375 E0.327 I3.535534 J3.535534 F600 G2 X45 Y50 Z0.875 E0.327 I5 J0 F600 G2 X46.464466 Y46.464466 Z0.90625 E0.327 I3.535534 J3.535534 F600 G2 X50 Y45 Z0.9375 E0.327 I0 J5 F600 G2 X53.535534 Y46.464466 Z0.96875 E0.327 I3.535534 J3.535534 F600 G2 X55 Y50 Z1 E0.327 I5 J0 F600 G2 X53.535534 Y53.535534 Z1.03125 E0.327 I3.535534 J3.535534 F600 G2 X50 Y55 Z1.0625 E0.327 I0 J5 F600 G2 X46.464466 Y53.535534 Z1.09375 E0.327 I3.535534 J3.535534 F600 G2 X45 Y50 Z1.125 E0.327 I5 J0 F600 G2 X46.464466 Y46.464466 Z1.15625 E0.327 I3.535534 J3.535534 F600 G2 X50 Y45 Z1.1875 E0.327 I0 J5 F600 G2 X53.535534 Y46.464466 Z1.21875 E0.327 I3.535534 J3.535534 F600 G2 X55 Y50 Z1.25 E0.327 I5 J0 F600 G2 X53.535534 Y53.535534 Z1.28125 E0.327 I3.535534 J3.535534 F600 G2 X50 Y55 Z1.3125 E0.327 I0 J5 F600 G2 X46.464466 Y53.535534 Z1.34375 E0.327 I3.535534 J3.535534 F600 G2 X45 Y50 Z1.375 E0.327 I5 J0 F600 G2 X46.464466 Y46.464466 Z1.40625 E0.327 I3.535534 J3.535534 F600 G2 X50 Y45 Z1.4375 E0.327 I0 J5 F600 G2 X53.535534 Y46.464466 Z1.46875 E0.327 I3.535534 J3.535534 F600 G2 X55 Y50 Z1.5 E0.327 I5 J0 F600 G2 X53.535534 Y53.535534 Z1.53125 E0.327 I3.535534 J3.535534 F600 G2 X50 Y55 Z1.5625 E0.327 I0 J5 F600 G2 X46.464466 Y53.535534 Z1.59375 E0.327 I3.535534 J3.535534 F600 G2 X45 Y50 Z1.625 E0.327 I5 J0 F600 G2 X46.464466 Y46.464466 Z1.65625 E0.327 I3.535534 J3.535534 F600 G2 X50 Y45 Z1.6875 E0.327 I0 J5 F600 G2 X53.535534 Y46.464466 Z1.71875 E0.327 I3.535534 J3.535534 F600 G2 X55 Y50 Z1.75 E0.327 I5 J0 F600 G2 X53.535534 Y53.535534 Z1.78125 E0.327 I3.535534 J3.535534 F600 G2 X50 Y55 Z1.8125 E0.327 I0 J5 F600 G2 X46.464466 Y53.535534 Z1.84375 E0.327 I3.535534 J3.535534 F600 G2 X45 Y50 Z1.875 E0.327 I5 J0 F600 G2 X46.464466 Y46.464466 Z1.90625 E0.327 I3.535534 J3.535534 F600 G2 X50 Y45 Z1.9375 E0.327 I0 J5 F600 G2 X53.535534 Y46.464466 Z1.96875 E0.327 I3.535534 J3.535534 F600 G2 X55 Y50 Z2 E0.327 I5 J0 F600 G2 X53.535534 Y53.535534 Z2.03125 E0.327 I3.535534 J3.535534 F600 G2 X50 Y55 Z2.0625 E0.327 I0 J5 F600 G2 X46.464466 Y53.535534 Z2.09375 E0.327 I3.535534 J3.535534 F600 G2 X45 Y50 Z2.125 E0.327 I5 J0 F600 G2 X46.464466 Y46.464466 Z2.15625 E0.327 I3.535534 J3.535534 F600 G2 X50 Y45 Z2.1875 E0.327 I0 J5 F600 G2 X53.535534 Y46.464466 Z2.21875 E0.327 I3.535534 J3.535534 F600 G2 X55 Y50 Z2.25 E0.327 I5 J0 F600 G2 X53.535534 Y53.535534 Z2.28125 E0.327 I3.535534 J3.535534 F600 G2 X50 Y55 Z2.3125 E0.327 I0 J5 F600 G2 X46.464466 Y53.535534 Z2.34375 E0.327 I3.535534 J3.535534 F600 G2 X45 Y50 Z2.375 E0.327 I5 J0 F600 G2 X46.464466 Y46.464466 Z2.40625 E0.327 I3.535534 J3.535534 F600 G2 X50 Y45 Z2.4375 E0.327 I0 J5 F600 G2 X53.535534 Y46.464466 Z2.46875 E0.327 I3.535534 J3.535534 F600 G2 X55 Y50 Z2.5 E0.327 I5 J0 F600 G10 G1 Y100 Z10 G91 ; relative positioning G1 Z5 F100 ; lift Z relative to current position
Other files not included because the message was identified incorrectly as spam. (I don't know what the rules are, but I'm pretty sure that they are written out somewhere...)

@MJLew If it's centered around (50,50) and you're starting at (55,50),
you could try something like this:; Quarter arc, starting (55,50), moving CW to (50,45). G1 X55 Y50 G2 X53.535534 Y46.464466 I5.000000 J+0.000000 G2 X50.000000 Y45.000000 I3.535533 J+3.535533
It looks like in your example, you might have CCW coordinates specified for a G2 CW arc move, which might be causing the spiral weirdness. Additionally it looks like your center point is defined relative to the destination point, rather than the start point. I think defining center relative to start point of the move is the intended usage.
In this case your formula would be something like:
I = Xcenter  X(start of move)
J = Ycenter  Y(start of move)which should work for both G2(CW) and G3 (CCW) moves

Your point about defining the centre relative to the ending points is probably exactly why I am getting the fluted cylinders! Thank you. I'll give it a burl with fixed up points.
(I am indeed using CCW coordinates for the G2 move, but that's just because I was unable to upload all of the examples I tried. They include CCW coordinates for G3 moves.)

Fixed! Thank you. Now I have a beautiful cylinder.

@MJLew Great! Thinking about it a bit more, as long as the center was specified correctly you would still get cylindrical motion with either CW or CCW command, just a matter of whether it goes the 'long way around' or not.
Now we just wait for radius mode to be fixed.

@nhof said in G2/G3 arcs with R parameter traverse the longer of the two arcs:
Now we just wait for radius mode to be fixed.
Should be fixed in 3.2beta 2 released yesterday.