<p>Marlin has <code>G2</code> (clockwise arc) and <code>G3</code> (counterclockwise arc) commands that could be used to do this. <a href="http://marlinfw.org/docs/gcode/G002-G003.html" rel="noreferrer">You can find detailed documentation for the command here.</a></p>

<p>Basically, you can use</p>

<blockquote>
  <p>G2 R1 X5 Y5</p>
</blockquote>

<p>to draw a (clockwise) arc from the current position to <span class="math-container">$(X,Y)=(5,5)$</span> with a radius of <span class="math-container">$1$</span>.</p>

<p>So, your rounded triangle could be drawn with 3 straight line moves and 3 arc moves. Figuring out the exact coordinates for each move would be a quite challenging geometry exercise, as you'd need to know where the straight line portion of each side ends and the rounded portion starts.</p>

CC BY-SA 4.0
2019-07-05T08:29:55.023Z
it's an easy exercise with a CAD though
Trish
CC BY-SA 4.0
2019-07-05T09:05:42.217Z
Do note that in the firmware support for G2/G3 must be enabled in the firmware, e.g. in Marlin by definition of `#define ARC_SUPPORT` in the Configuration_adv.h file. Also, shouldn't your printer board must have a sufficient capable processor to process the calculations for this option?
0scar
CC BY-SA 4.0
2019-07-05T09:07:55.537Z
@0scar circles are rather usual in CNC commands and most printer boards can double for those. I assume you might want to use the IJ argument instead of the R Argument though.
Trish
CC BY-SA 4.0
2019-07-06T06:54:16.867Z
@Trish The question specifies the G-code must be created "manually". I'm not sure if using CAD still counts as manual.
Tom van der Zanden
CC BY-SA 4.0
2019-07-05T08:18:42.833Z
2019-07-05T08:18:42.833Z
Tom van der Zanden
<p>First, convert the given measurements into a sketch...</p>
<p><a href="https://i.sstatic.net/ivxIW.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ivxIW.png" alt="Sketched out dimensions" /></a></p>
<h2>G-code shenanigans</h2>
<p>we actually have the printer do circles.. let's plot that out...</p>
<p><a href="https://i.sstatic.net/hGFSc.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/hGFSc.png" alt="Plotted all start-ends and centers" /></a></p>
<p>Using that, it's easy to write the G-code using the Documentation for <a href="http://marlinfw.org/docs/gcode/G000-G001.html" rel="nofollow noreferrer">G1</a> and <a href="http://marlinfw.org/docs/gcode/G002-G003.html" rel="nofollow noreferrer">G2</a>. You'll have to add the E values to extrude something along the paths, but your sketch would turn into this path:</p>
<pre><code>G92 X0 Y0 ; the current position is now (0,0) on the XY
G90 ;Abolute mode for everything...
M83 ;...but for the E-argument, so you can just put the length into the extrusions that are to be done
G0 X10.66 Y2 
G2 R5 X6.33 Y9.5 ; Alternate: G3 I0 J5 X6.33 Y9.5
G1 X45.66 Y77.638 
G2 R5 X54.33 Y77.638 ; Alternate: G3 I4.33 Y-2.5 X54.33 Y77.638
G1 93.67 Y9.5
G2 R5 X89.33 Y2 ; Alternate: G3 I-4.33 Y-2.5 X89.33 Y2
G1 X10.66 Y2
G0 X0 Y0
G91 ; return to relative coordinates
</code></pre>
<p><strong>This code has to be prefixed by a move to where you want to start the pattern</strong> and will <strong>not</strong> know if you move it off the build plate, so keep 100 mm X and 87 mm in Y of the allowable build plate. It will end exactly where you started it.</p>
<h2>Iterative approach</h2>
<p>In many uses of g-code, <em>rounded</em> corners are actually n-gons with a very high number n. then we only need <code>G1</code> and can easily calculate the length of the stretches and fill in the G1. We need to iterate down to somewhat circular...</p>
<p>Let's start iterating with n=3 aka a triangle, which gives a direct line over the corner gives this:</p>
<p><a href="https://i.sstatic.net/ANEnx.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ANEnx.png" alt="Iteration 1" /></a></p>
<p>going to n=6 (hexagon) follows the curve a lot better...</p>
<p><a href="https://i.sstatic.net/JRSMV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/JRSMV.png" alt="Iteration 2" /></a></p>
<p>going to n=12 looks almost round on a larger scale...</p>
<p><a href="https://i.sstatic.net/STTXL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/STTXL.png" alt="Iteration 3" /></a></p>
<p>and when we reach n=24, we are pretty close to the circle..</p>
<p><a href="https://i.sstatic.net/rO7dr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/rO7dr.png" alt="iteration 4" /></a></p>
<p>And as we go above n=6, we also get easier math for the corners, as we always get the same lengths of movement along X and Y just swapped around due to symmetry.</p>
<p>With all these stretches defined, we could start to work in <em>relative</em> coordinates easily, again without E, and only for the bottom left corner:</p>
<pre><code>G0 X10.66 Y2 
G1 X-1.294 Y0.17
G1 X-1.206 Y0.5
G1 X-1.036 Y0.795
G1 X-0.795 X1.036
G1 X-0.5 Y1.206
G1 X-0.17 Y1.294
G1 X0.17 Y1.294
G1 X0.5 Y1.036
...
</code></pre>

CC BY-SA 4.0
2019-07-05T16:50:53.123Z
Killer explanation ... love the graphics, which completely help the understanding. +1
Pᴀᴜʟsᴛᴇʀ2
CC BY-SA 4.0
2019-07-11T14:45:49.287Z
Beautifully illustrated, but it is responsive to the question  The question seemed to be about writing arcs in g-code, rather than how one could simulate arcs with line segments.
cmm
CC BY-SA 4.0
2019-07-05T08:52:11.370Z
2019-07-05T09:22:21.837Z
2020-06-18T08:29:41.667Z
Trish
<p>How can I write G-code for a triangle without sharp tips?</p>

<p><a href="https://i.sstatic.net/T0hpu.jpg" rel="nofollow noreferrer" title="Example of required triangle"><img src="https://i.sstatic.net/T0hpu.jpg" alt="Example of required triangle" title="Example of required triangle"></a></p>

<p>I want to generate the corners manually, rather than using a slicer to generate them, just to know how it is done.</p>

CC BY-SA 4.0
2019-07-04T17:18:42.057Z
your question is extremely terse. Do you want to generate the corners manually or do you want to understand how a slicer maces them? How a CAD does them?!
Trish
CC BY-SA 4.0
2019-07-05T06:23:56.363Z
With lots and lots of tiny segments.
towe
CC BY-SA 4.0
2019-07-05T11:40:29.697Z
@towe True, even if you use G2/G3
0scar
<g-code><cad>
How to write arcs directly in G-code?
GCODE2
# How to write arcs directly in G-code?

(Asked by: username_0 on 2019-07-04)

How can I write G-code for a triangle without sharp tips?

[![Example of required triangle](https://i.sstatic.net/T0hpu.jpg "Example of required triangle")](https://i.sstatic.net/T0hpu.jpg "Example of required triangle")

I want to generate the corners manually, rather than using a slicer to generate them, just to know how it is done.

**Tags:** g-code, cad
> **Comments:**
> **username_1**: your question is extremely terse. Do you want to generate the corners manually or do you want to understand how a slicer maces them? How a CAD does them?!  
> **username_2**: With lots and lots of tiny segments.  
> **username_3**: @towe True, even if you use G2/G3  

---

## 2 answers

### Answer by username_1 on 2019-07-05. Score: 6

First, convert the given measurements into a sketch...

G-code shenanigans
we actually have the printer do circles.. let's plot that out...

Using that, it's easy to write the G-code using the Documentation for G1 and G2. You'll have to add the E values to extrude something along the paths, but your sketch would turn into this path:
G92 X0 Y0 ; the current position is now (0,0) on the XY
G90 ;Abolute mode for everything...
M83 ;...but for the E-argument, so you can just put the length into the extrusions that are to be done
G0 X10.66 Y2 
G2 R5 X6.33 Y9.5 ; Alternate: G3 I0 J5 X6.33 Y9.5
G1 X45.66 Y77.638 
G2 R5 X54.33 Y77.638 ; Alternate: G3 I4.33 Y-2.5 X54.33 Y77.638
G1 93.67 Y9.5
G2 R5 X89.33 Y2 ; Alternate: G3 I-4.33 Y-2.5 X89.33 Y2
G1 X10.66 Y2
G0 X0 Y0
G91 ; return to relative coordinates

This code has to be prefixed by a move to where you want to start the pattern and will not know if you move it off the build plate, so keep 100 mm X and 87 mm in Y of the allowable build plate. It will end exactly where you started it.
Iterative approach
In many uses of g-code, rounded corners are actually n-gons with a very high number n. then we only need G1 and can easily calculate the length of the stretches and fill in the G1. We need to iterate down to somewhat circular...
Let's start iterating with n=3 aka a triangle, which gives a direct line over the corner gives this:

going to n=6 (hexagon) follows the curve a lot better...

going to n=12 looks almost round on a larger scale...

and when we reach n=24, we are pretty close to the circle..

And as we go above n=6, we also get easier math for the corners, as we always get the same lengths of movement along X and Y just swapped around due to symmetry.
With all these stretches defined, we could start to work in relative coordinates easily, again without E, and only for the bottom left corner:
G0 X10.66 Y2 
G1 X-1.294 Y0.17
G1 X-1.206 Y0.5
G1 X-1.036 Y0.795
G1 X-0.795 X1.036
G1 X-0.5 Y1.206
G1 X-0.17 Y1.294
G1 X0.17 Y1.294
G1 X0.5 Y1.036
...

> **Comments:**
> **username_5**: Killer explanation ... love the graphics, which completely help the understanding. +1  
> **username_6**: Beautifully illustrated, but it is responsive to the question  The question seemed to be about writing arcs in g-code, rather than how one could simulate arcs with line segments.  

---

### Answer by username_4 on 2019-07-05. Score: 5

Marlin has `G2` (clockwise arc) and `G3` (counterclockwise arc) commands that could be used to do this. [You can find detailed documentation for the command here.](http://marlinfw.org/docs/gcode/G002-G003.html)

Basically, you can use

> G2 R1 X5 Y5

to draw a (clockwise) arc from the current position to $(X,Y)=(5,5)$ with a radius of $1$.

So, your rounded triangle could be drawn with 3 straight line moves and 3 arc moves. Figuring out the exact coordinates for each move would be a quite challenging geometry exercise, as you'd need to know where the straight line portion of each side ends and the rounded portion starts.

> **Comments:**
> **username_1**: it's an easy exercise with a CAD though  
> **username_3**: Do note that in the firmware support for G2/G3 must be enabled in the firmware, e.g. in Marlin by definition of `#define ARC_SUPPORT` in the Configuration_adv.h file. Also, shouldn't your printer board must have a sufficient capable processor to process the calculations for this option?  
> **username_1**: @0scar circles are rather usual in CNC commands and most printer boards can double for those. I assume you might want to use the IJ argument instead of the R Argument though.  
> **username_4**: @Trish The question specifies the G-code must be created "manually". I'm not sure if using CAD still counts as manual.  

---

