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

Function isEarHashed

docs/app/js/sanddance-app.js:101805–101833  ·  view source on GitHub ↗
(ear, minX, minY, invSize)

Source from the content-addressed store, hash-verified

101803 return true;
101804}
101805function isEarHashed(ear, minX, minY, invSize) {
101806 const a = ear.prev;
101807 const b = ear;
101808 const c = ear.next;
101809 if (area(a, b, c) >= 0) return false;
101810 const minTX = a.x < b.x ? a.x < c.x ? a.x : c.x : b.x < c.x ? b.x : c.x;
101811 const minTY = a.y < b.y ? a.y < c.y ? a.y : c.y : b.y < c.y ? b.y : c.y;
101812 const maxTX = a.x > b.x ? a.x > c.x ? a.x : c.x : b.x > c.x ? b.x : c.x;
101813 const maxTY = a.y > b.y ? a.y > c.y ? a.y : c.y : b.y > c.y ? b.y : c.y;
101814 const minZ = zOrder(minTX, minTY, minX, minY, invSize);
101815 const maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
101816 let p = ear.prevZ;
101817 let n = ear.nextZ;
101818 while(p && p.z >= minZ && n && n.z <= maxZ){
101819 if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
101820 p = p.prevZ;
101821 if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
101822 n = n.nextZ;
101823 }
101824 while(p && p.z >= minZ){
101825 if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
101826 p = p.prevZ;
101827 }
101828 while(n && n.z <= maxZ){
101829 if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
101830 n = n.nextZ;
101831 }
101832 return true;
101833}
101834function cureLocalIntersections(start, triangles, dim) {
101835 let p = start;
101836 do {

Callers 1

earcutLinkedFunction · 0.70

Calls 3

areaFunction · 0.70
zOrderFunction · 0.70
pointInTriangleFunction · 0.70

Tested by

no test coverage detected