MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / windingArc

Method windingArc

src/common/overlay/levelRenderer/Area.js:790–847  ·  view source on GitHub ↗

* @function LevelRenderer.Tool.Areal.prototype.windingArc * // TODO Arc 旋转

(cx, cy, r, startAngle, endAngle, anticlockwise, x, y)

Source from the content-addressed store, hash-verified

788 * // TODO Arc 旋转
789 */
790 windingArc(cx, cy, r, startAngle, endAngle, anticlockwise, x, y) {
791 var roots = this.roots;
792 var PI2 = this.PI2;
793
794 y -= cy;
795 if (y > r || y < -r) {
796 return 0;
797 }
798 let tmp = Math.sqrt(r * r - y * y);
799 roots[0] = -tmp;
800 roots[1] = tmp;
801
802 if (Math.abs(startAngle - endAngle) >= PI2) {
803 // Is a circle
804 startAngle = 0;
805 endAngle = PI2;
806 var dir = anticlockwise ? 1 : -1;
807 if (x >= roots[0] + cx && x <= roots[1] + cx) {
808 return dir;
809 } else {
810 return 0;
811 }
812 }
813
814 if (anticlockwise) {
815 let tmp = startAngle;
816 startAngle = this.normalizeRadian(endAngle);
817 endAngle = this.normalizeRadian(tmp);
818 } else {
819 startAngle = this.normalizeRadian(startAngle);
820 endAngle = this.normalizeRadian(endAngle);
821 }
822 if (startAngle > endAngle) {
823 endAngle += PI2;
824 }
825
826 var w = 0;
827 for (let i = 0; i < 2; i++) {
828 var x_ = roots[i];
829 if (x_ + cx > x) {
830 let angle = Math.atan2(y, x_);
831 let dir = anticlockwise ? 1 : -1;
832 if (angle < 0) {
833 angle = PI2 + angle;
834 }
835 if (
836 (angle >= startAngle && angle <= endAngle)
837 || (angle + PI2 >= startAngle && angle + PI2 <= endAngle)
838 ) {
839 if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
840 dir = -dir;
841 }
842 w += dir;
843 }
844 }
845 }
846 return w;
847 }

Callers 2

isInsidePathMethod · 0.95
AreaSpec.jsFile · 0.80

Calls 1

normalizeRadianMethod · 0.95

Tested by

no test coverage detected