(ear, minX, minY, invSize)
| 69469 | } |
| 69470 | |
| 69471 | function isEarHashed(ear, minX, minY, invSize) { |
| 69472 | var a = ear.prev, |
| 69473 | b = ear, |
| 69474 | c = ear.next; |
| 69475 | |
| 69476 | if (area(a, b, c) >= 0) return false; // reflex, can't be an ear |
| 69477 | |
| 69478 | // triangle bbox; min & max are calculated like this for speed |
| 69479 | var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), |
| 69480 | minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), |
| 69481 | maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), |
| 69482 | maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); |
| 69483 | |
| 69484 | // z-order range for the current triangle bbox; |
| 69485 | var minZ = zOrder(minTX, minTY, minX, minY, invSize), |
| 69486 | maxZ = zOrder(maxTX, maxTY, minX, minY, invSize); |
| 69487 | |
| 69488 | var p = ear.prevZ, |
| 69489 | n = ear.nextZ; |
| 69490 | |
| 69491 | // look for points inside the triangle in both directions |
| 69492 | while (p && p.z >= minZ && n && n.z <= maxZ) { |
| 69493 | if (p !== ear.prev && p !== ear.next && |
| 69494 | pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && |
| 69495 | area(p.prev, p, p.next) >= 0) return false; |
| 69496 | p = p.prevZ; |
| 69497 | |
| 69498 | if (n !== ear.prev && n !== ear.next && |
| 69499 | pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && |
| 69500 | area(n.prev, n, n.next) >= 0) return false; |
| 69501 | n = n.nextZ; |
| 69502 | } |
| 69503 | |
| 69504 | // look for remaining points in decreasing z-order |
| 69505 | while (p && p.z >= minZ) { |
| 69506 | if (p !== ear.prev && p !== ear.next && |
| 69507 | pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && |
| 69508 | area(p.prev, p, p.next) >= 0) return false; |
| 69509 | p = p.prevZ; |
| 69510 | } |
| 69511 | |
| 69512 | // look for remaining points in increasing z-order |
| 69513 | while (n && n.z <= maxZ) { |
| 69514 | if (n !== ear.prev && n !== ear.next && |
| 69515 | pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && |
| 69516 | area(n.prev, n, n.next) >= 0) return false; |
| 69517 | n = n.nextZ; |
| 69518 | } |
| 69519 | |
| 69520 | return true; |
| 69521 | } |
| 69522 | |
| 69523 | // go through all polygon nodes and cure small local self-intersections |
| 69524 | function cureLocalIntersections(start, triangles, dim) { |
no test coverage detected