(ear, minX, minY, size)
| 1767 | } |
| 1768 | |
| 1769 | function isEarHashed(ear, minX, minY, size) { |
| 1770 | var a = ear.prev, |
| 1771 | b = ear, |
| 1772 | c = ear.next; |
| 1773 | |
| 1774 | if (area(a, b, c) >= 0) return false; // reflex, can't be an ear |
| 1775 | |
| 1776 | // triangle bbox; min & max are calculated like this for speed |
| 1777 | var minTX = a.x < b.x ? a.x < c.x ? a.x : c.x : b.x < c.x ? b.x : c.x, |
| 1778 | minTY = a.y < b.y ? a.y < c.y ? a.y : c.y : b.y < c.y ? b.y : c.y, |
| 1779 | maxTX = a.x > b.x ? a.x > c.x ? a.x : c.x : b.x > c.x ? b.x : c.x, |
| 1780 | maxTY = a.y > b.y ? a.y > c.y ? a.y : c.y : b.y > c.y ? b.y : c.y; |
| 1781 | |
| 1782 | // z-order range for the current triangle bbox; |
| 1783 | var minZ = zOrder(minTX, minTY, minX, minY, size), |
| 1784 | maxZ = zOrder(maxTX, maxTY, minX, minY, size); |
| 1785 | |
| 1786 | // first look for points inside the triangle in increasing z-order |
| 1787 | var p = ear.nextZ; |
| 1788 | |
| 1789 | while (p && p.z <= maxZ) { |
| 1790 | 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; |
| 1791 | p = p.nextZ; |
| 1792 | } |
| 1793 | |
| 1794 | // then look for points in decreasing z-order |
| 1795 | p = ear.prevZ; |
| 1796 | |
| 1797 | while (p && p.z >= minZ) { |
| 1798 | 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; |
| 1799 | p = p.prevZ; |
| 1800 | } |
| 1801 | |
| 1802 | return true; |
| 1803 | } |
| 1804 | |
| 1805 | // go through all polygon nodes and cure small local self-intersections |
| 1806 | function cureLocalIntersections(start, triangles, dim) { |
no test coverage detected