MCPcopy Create free account
hub / github.com/microsoft/SandDance / isValidDiagonal

Function isValidDiagonal

docs/tests/v2/es6/js/sanddance.js:69784–69789  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

69782
69783// check if a diagonal between two polygon nodes is valid (lies in polygon interior)
69784function isValidDiagonal(a, b) {
69785 return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
69786 (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
69787 (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
69788 equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case
69789}
69790
69791// signed area of a triangle
69792function area(p, q, r) {

Callers 1

splitEarcutFunction · 0.70

Calls 5

intersectsPolygonFunction · 0.70
locallyInsideFunction · 0.70
middleInsideFunction · 0.70
areaFunction · 0.70
equalsFunction · 0.70

Tested by

no test coverage detected