<p>I don't know how the clipping library you are using returns the clipped objects, but if I understand your question, you want a way to represent your circles that does not use much memory? If you are only using perfect circles (and not ellipses) you could represent each arc segment as simply an origin point, a radius, and a start/stop angle.</p>

<p>This is the part where it would be helpful to know what the clipping library returns. If it returns a chain of points as a separate object for each clipped arc segment, and you already know the radius and center of the circle (from before clipping), you could take the first and last point in the returned chain and compute the angle for each.</p>

<pre><code>atan2(x - origin.x, y - origin.y)
</code></pre>

<p>Then when you would like to draw the thing, you can write and algorithm to trace the arc going from the start to stop angle. If you want to do further clipping, you could recreate the arc as a chain of points.</p>

<p>Be careful about whether the returned segment was clockwise or counterclockwise.</p>

CC BY-SA 3.0
2017-12-18T00:51:02.303Z
The clipping library returns a list of points that make up the above figure. I cant distinguish between points that make up the arc and points that make up the lines.
user3453636
CC BY-SA 3.0
2017-12-18T04:17:53.030Z
So the dotted purple lines are part of the returned object? Well if the points in the arc are closely packed as you say, you can look at the distance between consecutive points. If that that distance is above some threshold then you can say that you've hit an edge of the arc.
Chuck
CC BY-SA 3.0
2017-12-17T21:59:40.770Z
2017-12-17T21:59:40.770Z
Chuck
<p>You cannot use Clipper and expect analytical results. Circle arcs will be composed by line segments. That said, you know your boolean operands so it should be possible and fairly easy to map all line segments back to their origin operand and extract the arcs yourself.</p>

CC BY-SA 4.0
2023-03-28T07:38:41.683Z
Well, find all intersections between the circle and the polygon's line segments (for the circle parameterized by t), the circle segments will alternate between in and out, one of these you should be able to determine as in or out, and then you're done. Fairly easy.
beyond
CC BY-SA 4.0
2023-03-28T07:54:51.287Z
You're right, I never did. Thanks for correcting me.
beyond
CC BY-SA 4.0
2018-08-17T08:22:36.720Z
2018-08-17T08:22:36.720Z
beyond
<p>I'm developing a CAD drawing generator using C# and netdxf library (<a href="https://github.com/haplokuon/netDxf" rel="nofollow noreferrer">https://github.com/haplokuon/netDxf</a>)</p>

<p>The app first performs boolean operations (specifically - union &amp; subtraction) on polygons and draws the resultant path on .dxf file.</p>

<p>I'm using Angus johnson's Clipper library (<a href="http://www.angusj.com/delphi/clipper.php" rel="nofollow noreferrer">Clipper - an open source freeware polygon clipping library | angusj.com</a>) for clipping </p>

<p>Everything works fine for polygons, The problem is when I need to clip circles and polygons, the result is a large list of points (representing the path of the figure to be drawn on dxf)</p>

<p>So the curved portion of the path is composed of tiny segments, which is a big problem for the CAM software that'd be used later. </p>

<p>Below is such an image (the result of clipping circle and polygon). The grey portion is full of tiny line segments</p>

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

<p>Questions - </p>

<p>1) How can I convert those tiny line segments to circles/arcs using the list of points?</p>

<p>2) Can I take a completely different approach to avoid this problem?</p>

<p>Thanks!</p>

<polygon><clipping><cad>
Clipping circle and polygon and generate a CAD drawing
user3453636
# Clipping circle and polygon and generate a CAD drawing

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

I'm developing a CAD drawing generator using C# and netdxf library (<https://github.com/haplokuon/netDxf>)

The app first performs boolean operations (specifically - union & subtraction) on polygons and draws the resultant path on .dxf file.

I'm using Angus johnson's Clipper library ([Clipper - an open source freeware polygon clipping library | angusj.com](http://www.angusj.com/delphi/clipper.php)) for clipping

Everything works fine for polygons, The problem is when I need to clip circles and polygons, the result is a large list of points (representing the path of the figure to be drawn on dxf)

So the curved portion of the path is composed of tiny segments, which is a big problem for the CAM software that'd be used later.

Below is such an image (the result of clipping circle and polygon). The grey portion is full of tiny line segments

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

Questions -

1) How can I convert those tiny line segments to circles/arcs using the list of points?

2) Can I take a completely different approach to avoid this problem?

Thanks!

**Tags:** polygon, clipping, cad


---

## 2 answers

### Answer by username_1 on 2017-12-17. Score: 1

I don't know how the clipping library you are using returns the clipped objects, but if I understand your question, you want a way to represent your circles that does not use much memory? If you are only using perfect circles (and not ellipses) you could represent each arc segment as simply an origin point, a radius, and a start/stop angle.

This is the part where it would be helpful to know what the clipping library returns. If it returns a chain of points as a separate object for each clipped arc segment, and you already know the radius and center of the circle (from before clipping), you could take the first and last point in the returned chain and compute the angle for each.

```
atan2(x - origin.x, y - origin.y)

```

Then when you would like to draw the thing, you can write and algorithm to trace the arc going from the start to stop angle. If you want to do further clipping, you could recreate the arc as a chain of points.

Be careful about whether the returned segment was clockwise or counterclockwise.

> **Comments:**
> **username_0**: The clipping library returns a list of points that make up the above figure. I cant distinguish between points that make up the arc and points that make up the lines.  
> **username_1**: So the dotted purple lines are part of the returned object? Well if the points in the arc are closely packed as you say, you can look at the distance between consecutive points. If that that distance is above some threshold then you can say that you've hit an edge of the arc.  

---

### Answer by username_2 on 2018-08-17. Score: 0

You cannot use Clipper and expect analytical results. Circle arcs will be composed by line segments. That said, you know your boolean operands so it should be possible and fairly easy to map all line segments back to their origin operand and extract the arcs yourself.

> **Comments:**
> **username_2**: Well, find all intersections between the circle and the polygon's line segments (for the circle parameterized by t), the circle segments will alternate between in and out, one of these you should be able to determine as in or out, and then you're done. Fairly easy.  
> **username_2**: You're right, I never did. Thanks for correcting me.  

---

