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

Function isValidDiagonal

docs/app/js/sanddance-app.js:102028–102030  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

102026 return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
102027}
102028function isValidDiagonal(a, b) {
102029 return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (area(a.prev, a, b.prev) || area(a, b.prev, b)) || equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
102030}
102031function area(p, q, r) {
102032 return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
102033}

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