<p>I've not done CSG per se, but I did work on a, not-unrelated, problem of triangulation of arbitrary, self-intersecting, multi-contoured polygons. If you don't get the implicit intersections correct, all sorts of nasty artefacts can result.</p>

<p>Initially, I tried using standard, floating-point maths to compute intersections etc, but this is fraught with precision problems and no amount of trickery of ordering etc eliminated these accuracy issues.</p>

<p>In the end, I replaced all intersection calculations with rational maths (high precision integer numerator and denominators) with sufficient precision that all intersections would be represented <em>exactly</em>. Once the process was completed, then these high precision results could be reduced to back to floating point.</p>

<p>Perhaps a quick way to start would be to use a package such as <a href="https://gmplib.org/" rel="nofollow noreferrer">GNU's GMP</a> which supports arbitrary rational representations.</p>

CC BY-SA 4.0
2018-08-22T09:06:54.760Z
2018-08-22T09:06:54.760Z
Simon F
<p>I have used a library to perform a Constructive Solid Geometry difference operation, which has left me with orphaned geometry as well as imperfections.</p>

<p>Is there an approach/algorithm that will allow me clean the geometry so all that remains is the two cuboids?</p>

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

CC BY-SA 4.0
2018-08-22T07:53:05.870Z
In order to be able to help you, you should post a describtion of what you want to do, which boolean operation(s) that you have carried out, their order, the operands, your expectations and the difference between your expections and the actual output. Including pictures. Also: Which library have you used, and do you have examples where it performs as you expect?
beyond
<computational-geometry><geometry>
Remove orphaned geometry after Constructive Solid Geometry operation
pingu
# Remove orphaned geometry after Constructive Solid Geometry operation

(Asked by: username_0 on 2018-08-19)

I have used a library to perform a Constructive Solid Geometry difference operation, which has left me with orphaned geometry as well as imperfections.

Is there an approach/algorithm that will allow me clean the geometry so all that remains is the two cuboids?

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

**Tags:** computational-geometry, geometry

> **Comments:**
> **username_1**: In order to be able to help you, you should post a describtion of what you want to do, which boolean operation(s) that you have carried out, their order, the operands, your expectations and the difference between your expections and the actual output. Including pictures. Also: Which library have you used, and do you have examples where it performs as you expect?  

---

## 1 answers

### Answer by username_2 on 2018-08-22. Score: 1

I've not done CSG per se, but I did work on a, not-unrelated, problem of triangulation of arbitrary, self-intersecting, multi-contoured polygons. If you don't get the implicit intersections correct, all sorts of nasty artefacts can result.

Initially, I tried using standard, floating-point maths to compute intersections etc, but this is fraught with precision problems and no amount of trickery of ordering etc eliminated these accuracy issues.

In the end, I replaced all intersection calculations with rational maths (high precision integer numerator and denominators) with sufficient precision that all intersections would be represented *exactly*. Once the process was completed, then these high precision results could be reduced to back to floating point.

Perhaps a quick way to start would be to use a package such as [GNU's GMP](https://gmplib.org/) which supports arbitrary rational representations.


---

