(vList, vx, angleDif, lengthDif)
| 524 | |
| 525 | |
| 526 | def Smooth(vList, vx, angleDif, lengthDif): |
| 527 | end = False |
| 528 | while not end: |
| 529 | if len(vList) < 4: |
| 530 | break |
| 531 | k = -1 |
| 532 | for i in range(len(vList)): |
| 533 | if i < len(vList) - 1: |
| 534 | k = i + 1 |
| 535 | if i == len(vList) - 1: |
| 536 | end = True |
| 537 | k = 0 |
| 538 | |
| 539 | v1 = vList[i] |
| 540 | v2 = vList[k] |
| 541 | angle = v1.cos(v2) |
| 542 | |
| 543 | if min([angle, math.fabs(180 - angle)]) < angleDif: |
| 544 | v = Vector(v1.x1, v1.y1, v2.x2, v2.y2, v1.index) |
| 545 | vList.remove(v1) |
| 546 | vList.remove(v2) |
| 547 | if v.checkV(): |
| 548 | vList.insert(i, v) |
| 549 | break |
| 550 | |
| 551 | if ( |
| 552 | math.fabs(90 - angle) < angleDif - 5 |
| 553 | and math.fabs(90 - angle) > 1 |
| 554 | and v1.length() < lengthDif |
| 555 | and v2.length() < lengthDif |
| 556 | ): |
| 557 | v1Angle = v1.cos(vx) |
| 558 | v2Angle = v2.cos(vx) |
| 559 | |
| 560 | if ( |
| 561 | math.fabs(90 - v1Angle) < angleDif and math.fabs(90 - v1Angle) > 1 |
| 562 | ) or ( |
| 563 | math.fabs(90 - v2Angle) < angleDif and math.fabs(90 - v2Angle) > 1 |
| 564 | ): |
| 565 | x, y = IntersectPt(v1, v2, vx) |
| 566 | vList.remove(v1) |
| 567 | vList.remove(v2) |
| 568 | ov1 = Vector(v1.x1, v1.y1, x, y, v1.index) |
| 569 | if ov1.checkV(): |
| 570 | vList.insert(i, ov1) |
| 571 | ov2 = Vector(x, y, v2.x2, v2.y2, v1.index + 1) |
| 572 | if ov2.checkV(): |
| 573 | vList.insert(k, ov2) |
| 574 | break |
| 575 | |
| 576 | return vList |
| 577 | |
| 578 | |
| 579 | def Domain(v1, v2, angleDiff, area, lengthDiff): |
no test coverage detected