<p>I suppose you want an arc of C0 and C1 continuity between the line and an arc.
<a href="https://i.sstatic.net/VC5L4.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/VC5L4.png" alt="Rounding corner illustration"></a></p>

<p>As illustrated above, you already have a vertex A which is the intersection of an edge and an arc of which the center positioned at O and radius equal to R. The question is thus pure mathematical: given A,O,R, edge direction BA, and a corner radius r, find C,B, and T.
For simplicity, here let's assume that the black dotted line has the form of $C_y=kC_x+b$, where k is the same as edge BA while b is easily derived by combining k and rounding radius r. Therefore, three constraint equations can be listed to solve $C_x$:</p>

<ol>
<li>The distance TC is r: $(T_x-C_x)^2+(T_y-C_y)^2=r^2$</li>
<li>The big arc equation: $(T_x-O_x)^2+(T_y-O_y)^2=R^2$</li>
<li>Point C is on OT: $\frac{T_y-C_y}{T_x-C_x}=\frac{T_y-O_y}{T_x-O_x}$</li>
</ol>

<p>Solve for Cx and you'll obtain four solutions (I used Mathematica):</p>

<p>$C_x=\frac{-bk+O_x+kO_y\pm\sqrt{-(O_y-kO_x-b)^2+(1+k^2)(R-r)^2}}{1+k^2}$
$C_x=\frac{-bk+O_x+kO_y\pm\sqrt{-(O_y-kO_x-b)^2+(1+k^2)(R+r)^2}}{1+k^2}$</p>

<p>The second expression is out of the arc, so you should use the first solutions. Given the two Cx values, they can be used to derive Cy values to make a candidate list for point C. Pick the correct C using manual check.</p>

<p>Now you have the center C of the round corner arc as well as its radius r. It should be relatively easy to determine point B and point T, and draw an arc through the two points.</p>

CC BY-SA 3.0
2017-12-26T17:42:23.180Z
2017-12-26T17:58:31.897Z
2017-12-26T17:58:31.897Z
Xenapior
<p>Given shapes like these, which contain just Arcs and lines, I want to round all its corners with certain radius. I know the vertices of the lines &amp; arcs these shapes.</p>

<p><a href="https://i.sstatic.net/F1Hlh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/F1Hlh.png" alt="enter image description here"></a></p>

<p>I can round the corners of a polygon (when two lines meet to form a corner), but can't figure out how to round a corner formed by an Arc and a Line.</p>

<p>I used this post to round the corners of polygon:</p>

<p><a href="https://stackoverflow.com/questions/24771828/algorithm-for-creating-rounded-corners-in-a-polygon">Algorithm for creating rounded corners in a polygon | Stack Overflow</a></p>

<p>Could you please share a code snippet, or just explain/list the math/algorithm behind achieving this? Thanks!</p>

<p>PS: I'm developing a CAD drawing generator using C# &amp; .netDxf library</p>

<computational-geometry><geometry><polygon><edge-detection><cad>
Rounding a corner formed by Arc and Line
user3453636
# Rounding a corner formed by Arc and Line

(Asked by: username_0 on 2017-12-22)

Given shapes like these, which contain just Arcs and lines, I want to round all its corners with certain radius. I know the vertices of the lines & arcs these shapes.

[![enter image description here](https://i.sstatic.net/F1Hlh.png)](https://i.sstatic.net/F1Hlh.png)

I can round the corners of a polygon (when two lines meet to form a corner), but can't figure out how to round a corner formed by an Arc and a Line.

I used this post to round the corners of polygon:

[Algorithm for creating rounded corners in a polygon | Stack Overflow](https://stackoverflow.com/questions/24771828/algorithm-for-creating-rounded-corners-in-a-polygon)

Could you please share a code snippet, or just explain/list the math/algorithm behind achieving this? Thanks!

PS: I'm developing a CAD drawing generator using C# & .netDxf library

**Tags:** computational-geometry, geometry, polygon, edge-detection, cad


---

## 1 answers

### Answer by username_1 on 2017-12-26. Score: 2

I suppose you want an arc of C0 and C1 continuity between the line and an arc.
[![Rounding corner illustration](https://i.sstatic.net/VC5L4.png)](https://i.sstatic.net/VC5L4.png)

As illustrated above, you already have a vertex A which is the intersection of an edge and an arc of which the center positioned at O and radius equal to R. The question is thus pure mathematical: given A,O,R, edge direction BA, and a corner radius r, find C,B, and T.
For simplicity, here let's assume that the black dotted line has the form of $C\_y=kC\_x+b$, where k is the same as edge BA while b is easily derived by combining k and rounding radius r. Therefore, three constraint equations can be listed to solve $C\_x$:

1. The distance TC is r: $(T\_x-C\_x)^2+(T\_y-C\_y)^2=r^2$
2. The big arc equation: $(T\_x-O\_x)^2+(T\_y-O\_y)^2=R^2$
3. Point C is on OT: $\frac{T\_y-C\_y}{T\_x-C\_x}=\frac{T\_y-O\_y}{T\_x-O\_x}$

Solve for Cx and you'll obtain four solutions (I used Mathematica):

$C\_x=\frac{-bk+O\_x+kO\_y\pm\sqrt{-(O\_y-kO\_x-b)^2+(1+k^2)(R-r)^2}}{1+k^2}$
$C\_x=\frac{-bk+O\_x+kO\_y\pm\sqrt{-(O\_y-kO\_x-b)^2+(1+k^2)(R+r)^2}}{1+k^2}$

The second expression is out of the arc, so you should use the first solutions. Given the two Cx values, they can be used to derive Cy values to make a candidate list for point C. Pick the correct C using manual check.

Now you have the center C of the round corner arc as well as its radius r. It should be relatively easy to determine point B and point T, and draw an arc through the two points.


---

