* @function LevelRenderer.Tool.Areal.prototype.windingQuadratic
(x0, y0, x1, y1, x2, y2, x, y)
| 743 | * @function LevelRenderer.Tool.Areal.prototype.windingQuadratic |
| 744 | */ |
| 745 | windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) { |
| 746 | var curve = this.curve; |
| 747 | var roots = this.roots; |
| 748 | |
| 749 | // Quick reject |
| 750 | if ( |
| 751 | (y > y0 && y > y1 && y > y2) |
| 752 | || (y < y0 && y < y1 && y < y2) |
| 753 | ) { |
| 754 | return 0; |
| 755 | } |
| 756 | var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots); |
| 757 | if (nRoots === 0) { |
| 758 | return 0; |
| 759 | } else { |
| 760 | var t = curve.quadraticExtremum(y0, y1, y2); |
| 761 | if (t >= 0 && t <= 1) { |
| 762 | var w = 0; |
| 763 | var y_ = curve.quadraticAt(y0, y1, y2, t); |
| 764 | for (let i = 0; i < nRoots; i++) { |
| 765 | let x_ = curve.quadraticAt(x0, x1, x2, roots[i]); |
| 766 | if (x_ > x) { |
| 767 | continue; |
| 768 | } |
| 769 | if (roots[i] < t) { |
| 770 | w += y_ < y0 ? 1 : -1; |
| 771 | } else { |
| 772 | w += y2 < y_ ? 1 : -1; |
| 773 | } |
| 774 | } |
| 775 | return w; |
| 776 | } else { |
| 777 | let x_ = curve.quadraticAt(x0, x1, x2, roots[0]); |
| 778 | if (x_ > x) { |
| 779 | return 0; |
| 780 | } |
| 781 | return y2 < y0 ? 1 : -1; |
| 782 | } |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | /** |
| 787 | * @function LevelRenderer.Tool.Areal.prototype.windingArc |
no test coverage detected