evanw / evanw/csg.js

Bug in splitting algorithm

Open
#11 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.9k
Forks
264
PR merge metrics
No merged PRs in 30d

Description

The following code will result in an endless recursion. I think this is a problem due to rounding errors. The first poly is a triangle, the second poly is a quad.

```
var l = [], polys = [];

l.push(new CSG.Vertex(new CSG.Vector(1.23079, 0.35525, -0.39928), new CSG.Vector(0, 0, 0)));
l.push(new CSG.Vertex(new CSG.Vector(1.26563, 0.28906, -0.40625), new CSG.Vector(0, 0, 0)));
l.push(new CSG.Vertex(new CSG.Vector(1.24346, 0.44424, -0.41733), new CSG.Vector(0, 0, 0)));
polys.push(new CSG.Polygon(l));

var l2 = [];
l2.push(new CSG.Vertex(new CSG.Vector(1.26216, 0.46369, -0.43822), new CSG.Vector(0, 0, 0)));
l2.push(new CSG.Vertex(new CSG.Vector(1.36719, 0.29688, -0.50000), new CSG.Vector(0, 0, 0)));
l2.push(new CSG.Vertex(new CSG.Vector(1.35204, 0.32133, -0.34461), new CSG.Vector(0, 0, 0)));
l2.push(new CSG.Vertex(new CSG.Vector(1.25679, 0.47373, -0.34461), new CSG.Vector(0, 0, 0)));
polys.push(new CSG.Polygon(l2));
var res = CSG.fromPolygons(polys);

var a = new CSG.Node(res.toPolygons());
var result = a.AllPolygons();
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.