MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / isEar

Function isEar

libs/mapv/mapv.js:1751–1767  ·  view source on GitHub ↗
(ear)

Source from the content-addressed store, hash-verified

1749
1750// check whether a polygon node forms a valid ear with adjacent nodes
1751function isEar(ear) {
1752 var a = ear.prev,
1753 b = ear,
1754 c = ear.next;
1755
1756 if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
1757
1758 // now make sure we don't have other points inside the potential ear
1759 var p = ear.next.next;
1760
1761 while (p !== ear.prev) {
1762 if (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;
1763 p = p.next;
1764 }
1765
1766 return true;
1767}
1768
1769function isEarHashed(ear, minX, minY, size) {
1770 var a = ear.prev,

Callers 1

earcutLinkedFunction · 0.85

Calls 2

areaFunction · 0.85
pointInTriangleFunction · 0.85

Tested by

no test coverage detected