<p>Since you're working on CAD software, you probably want some precise results. Here an algorithm that could work:</p>

<p>For each side:</p>

<ul>
<li>Compute the segment's equation.</li>
<li>Compute each round corner's circle equation.</li>
<li>Compute the intersections between the segment and each circle.</li>
<li>The 2 intersection points are the new endpoints for the line segment.</li>
</ul>

<p>This doesn't handle the case where a side is smaller than the rounded corner radius. You could reduce the rounded corner's radius in this case based on the segment's length.</p>

CC BY-SA 3.0
2017-11-21T23:54:37.403Z
2017-11-21T23:54:37.403Z
bernie
<p>Ok, Xenapior and Reynolds together have the right idea. But the explanation is a bit lacking so here is a image to explain it all and some further musings. First let us  start by drawing an image (yes i know that is what they say in school for you to do but nobody does it).</p>

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

<p>From the image we can see that there are 2 equal right triangles $V_2, A, C$ and $V_1, B, C$. In this triangle we have one unknown that we can define namely rounding radius $r$, also we know right angle is 90&deg;. The angle between the line $V_1-V_2 = \vec a$ and line $V_2-V_3 = \vec b$ is easy to compute with  the formulation fo angle between vectors</p>

<p>$$\cos(\beta) = \frac{\vec a·\vec b}{ |\vec a|·|\vec b|}$$</p>

<p>That in turn can be simplified if the vectors already are normal. Thus three things of the triangle is known, which means all is known. So if you know the rounding radius to use the calculating the points $A$, $B$ and $C$. So finally:</p>

<pre><code>a = normalize(V2-V1);
b = normalize(V2-V3);
halfang = acos(dot(a, b))/2.;
// skip center if you iuse splines
C = V2 - r / sin(halfang) * normalize((a+b)/2);
A = V2 - r/tan(halfang)*a;
B = V2 - r/tan(halfang)*b;
</code></pre>

<p>You can simplify this a bit with trigonometric identities. Or if you use rational B-splines you can skip the calculation of C</p>

<p><strong>Note</strong>: that this is only one possible formulation</p>

CC BY-SA 3.0
2017-11-23T09:27:54.870Z
2017-11-24T12:42:05.647Z
2017-11-24T12:42:05.647Z
joojaa
<p>The cut length from the vertex is x*ctan(t/2), where t is the angle at this vertex.</p>

CC BY-SA 3.0
2017-11-23T02:31:47.267Z
2017-11-23T02:31:47.267Z
Xenapior
<p>Given a polygon (regular or irregular, convex or concave), I want to round its corner, with a given radius; let's say 'x'. I have the code to draw an arc given 2 points, but how can I find the start and end points of the arc?</p>

<p>All I have is a list of points representing each corner of the polygon.</p>

<p>Here's a simple example: I have a list of vertices of corners of the figure (1). 
The figure (2) is what I need so I could draw the arcs to round the corners.</p>

<p>PS: I'm developing a CAD drawing generator using .netdxf API (<a href="https://github.com/haplokuon/netDxf" rel="nofollow noreferrer">https://github.com/haplokuon/netDxf</a>)</p>

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

<polygon><2d-graphics><cad>
Rounding corners of polygon given vertices of its corners
user3453636
# Rounding corners of polygon given vertices of its corners

(Asked by: username_0 on 2017-11-21)

Given a polygon (regular or irregular, convex or concave), I want to round its corner, with a given radius; let's say 'x'. I have the code to draw an arc given 2 points, but how can I find the start and end points of the arc?

All I have is a list of points representing each corner of the polygon.

Here's a simple example: I have a list of vertices of corners of the figure (1).
The figure (2) is what I need so I could draw the arcs to round the corners.

PS: I'm developing a CAD drawing generator using .netdxf API (<https://github.com/haplokuon/netDxf>)

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

**Tags:** polygon, 2d-graphics, cad


---

## 3 answers

### Answer by username_1 on 2017-11-21. Score: 1 | Accepted answer

Since you're working on CAD software, you probably want some precise results. Here an algorithm that could work:

For each side:

* Compute the segment's equation.
* Compute each round corner's circle equation.
* Compute the intersections between the segment and each circle.
* The 2 intersection points are the new endpoints for the line segment.

This doesn't handle the case where a side is smaller than the rounded corner radius. You could reduce the rounded corner's radius in this case based on the segment's length.


---

### Answer by username_2 on 2017-11-23. Score: 6

Ok, username_3 and Reynolds together have the right idea. But the explanation is a bit lacking so here is a image to explain it all and some further musings. First let us start by drawing an image (yes i know that is what they say in school for you to do but nobody does it).

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

From the image we can see that there are 2 equal right triangles $V\_2, A, C$ and $V\_1, B, C$. In this triangle we have one unknown that we can define namely rounding radius $r$, also we know right angle is 90°. The angle between the line $V\_1-V\_2 = \vec a$ and line $V\_2-V\_3 = \vec b$ is easy to compute with the formulation fo angle between vectors

$$\cos(\beta) = \frac{\vec a·\vec b}{ |\vec a|·|\vec b|}$$

That in turn can be simplified if the vectors already are normal. Thus three things of the triangle is known, which means all is known. So if you know the rounding radius to use the calculating the points $A$, $B$ and $C$. So finally:

```
a = normalize(V2-V1);
b = normalize(V2-V3);
halfang = acos(dot(a, b))/2.;
// skip center if you iuse splines
C = V2 - r / sin(halfang) * normalize((a+b)/2);
A = V2 - r/tan(halfang)*a;
B = V2 - r/tan(halfang)*b;

```

You can simplify this a bit with trigonometric identities. Or if you use rational B-splines you can skip the calculation of C

**Note**: that this is only one possible formulation


---

### Answer by username_3 on 2017-11-23. Score: 1

The cut length from the vertex is x\*ctan(t/2), where t is the angle at this vertex.


---

