@antv/g-math
Advanced tools
Comparing version 1.7.44 to 1.7.45
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.Math={}))}(this,(function(t){"use strict";function n(t,n,r,a){var o=t-r,e=n-a;return Math.sqrt(o*o+e*e)}function r(t,n){return.001>Math.abs(t-n)}function a(t,n){var r=Math.min.apply(Math,t),a=Math.min.apply(Math,n);return{x:r,y:a,width:Math.max.apply(Math,t)-r,height:Math.max.apply(Math,n)-a}}function o(t){return(t+2*Math.PI)%(2*Math.PI)}var e=Object.freeze({__proto__:null,distance:n,isNumberEqual:r,getBBoxByArray:a,getBBoxRange:function(t,n,r,a){return{minX:Math.min(t,r),maxX:Math.max(t,r),minY:Math.min(n,a),maxY:Math.max(n,a)}},piMod:o}),i="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var t=0,n=arguments.length;n--;)t+=arguments[n]*arguments[n];return Math.sqrt(t)});u=new i(2),i!=Float32Array&&(u[0]=0,u[1]=0),h=u;var u,h,f={box:function(t,n,r,o){return a([t,r],[n,o])},length:function(t,r,a,o){return n(t,r,a,o)},pointAt:function(t,n,r,a,o){return{x:(1-o)*t+o*r,y:(1-o)*n+o*a}},pointDistance:function(t,r,a,o,e,i){var u=(a-t)*(e-t)+(o-r)*(i-r);return 0>u?n(t,r,e,i):u>(a-t)*(a-t)+(o-r)*(o-r)?n(a,o,e,i):this.pointToLine(t,r,a,o,e,i)},pointToLine:function(t,n,r,a,o,e){var i=[r-t,a-n];if(function(t,n){return t[0]===n[0]&&t[1]===n[1]}(i,[0,0]))return Math.sqrt((o-t)*(o-t)+(e-n)*(e-n));var u=[-i[1],i[0]];return function(t,n){var r=n[0],a=n[1],o=r*r+a*a;o>0&&(o=1/Math.sqrt(o)),t[0]=n[0]*o,t[1]=n[1]*o}(u,u),Math.abs(function(t,n){return t[0]*n[0]+t[1]*n[1]}([o-t,e-n],u))},tangentAngle:function(t,n,r,a){return Math.atan2(a-n,r-t)}},c=1e-4;function p(t,r,a,o,e,i){var u=-1,h=1/0,f=[a,o],p=20;i&&i>200&&(p=i/10);for(var s=1/p,v=s/10,M=0;p>=M;M++){var l=M*s,y=[e.apply(void 0,t.concat([l])),e.apply(void 0,r.concat([l]))],g=n(f[0],f[1],y[0],y[1]);h>g&&(u=l,h=g)}if(0===u)return{x:t[0],y:r[0]};if(1===u){var x=t.length;return{x:t[x-1],y:r[x-1]}}h=1/0;for(var d=0;32>d&&c<=v;d++){var A=u-v,m=u+v,b=[e.apply(void 0,t.concat([A])),e.apply(void 0,r.concat([A]))],P=n(f[0],f[1],b[0],b[1]);if(A>=0&&h>P)u=A,h=P;else{var I=[e.apply(void 0,t.concat([m])),e.apply(void 0,r.concat([m]))],q=n(f[0],f[1],I[0],I[1]);1>=m&&h>q?(u=m,h=q):v*=.5}}return{x:e.apply(void 0,t.concat([u])),y:e.apply(void 0,r.concat([u]))}}function s(t,n,r,a){var o=1-a;return o*o*t+2*a*o*n+a*a*r}function v(t,n,a){var o=t+a-2*n;if(r(o,0))return[.5];var e=(t-n)/o;return e>1||0>e?[]:[e]}function M(t,n,r,a){return 2*(1-a)*(n-t)+2*a*(r-n)}function l(t,n,r,a,o,e,i){var u=s(t,r,o,i),h=s(n,a,e,i),c=f.pointAt(t,n,r,a,i),p=f.pointAt(r,a,o,e,i);return[[t,n,c.x,c.y,u,h],[u,h,p.x,p.y,o,e]]}function y(t,r,a,o,e,i,u){if(0===u)return(n(t,r,a,o)+n(a,o,e,i)+n(t,r,e,i))/2;var h=l(t,r,a,o,e,i,.5),f=h[0],c=h[1];return f.push(u-1),c.push(u-1),y.apply(void 0,f)+y.apply(void 0,c)}var g={box:function(t,n,r,o,e,i){var u=v(t,r,e)[0],h=v(n,o,i)[0],f=[t,e],c=[n,i];return void 0!==u&&f.push(s(t,r,e,u)),void 0!==h&&c.push(s(n,o,i,h)),a(f,c)},length:function(t,n,r,a,o,e){return y(t,n,r,a,o,e,3)},nearestPoint:function(t,n,r,a,o,e,i,u){return p([t,r,o],[n,a,e],i,u,s)},pointDistance:function(t,r,a,o,e,i,u,h){var f=this.nearestPoint(t,r,a,o,e,i,u,h);return n(f.x,f.y,u,h)},interpolationAt:s,pointAt:function(t,n,r,a,o,e,i){return{x:s(t,r,o,i),y:s(n,a,e,i)}},divide:function(t,n,r,a,o,e,i){return l(t,n,r,a,o,e,i)},tangentAngle:function(t,n,r,a,e,i,u){var h=M(t,r,e,u),f=M(n,a,i,u);return o(Math.atan2(f,h))}};function x(t,n,r,a,o){var e=1-o;return e*e*e*t+3*n*o*e*e+3*r*o*o*e+a*o*o*o}function d(t,n,r,a,o){var e=1-o;return 3*(e*e*(n-t)+2*e*o*(r-n)+o*o*(a-r))}function A(t,n,a,o){var e,i,u,h=-3*t+9*n-9*a+3*o,f=6*t-12*n+6*a,c=3*n-3*t,p=[];if(r(h,0))r(f,0)||0>(e=-c/f)||e>1||p.push(e);else{var s=f*f-4*h*c;r(s,0)?p.push(-f/(2*h)):s>0&&(i=(-f-(u=Math.sqrt(s)))/(2*h),0>(e=(-f+u)/(2*h))||e>1||p.push(e),0>i||i>1||p.push(i))}return p}function m(t,n,r,a,o,e,i,u,h){var c=x(t,r,o,i,h),p=x(n,a,e,u,h),s=f.pointAt(t,n,r,a,h),v=f.pointAt(r,a,o,e,h),M=f.pointAt(o,e,i,u,h),l=f.pointAt(s.x,s.y,v.x,v.y,h),y=f.pointAt(v.x,v.y,M.x,M.y,h);return[[t,n,s.x,s.y,l.x,l.y,c,p],[c,p,y.x,y.y,M.x,M.y,i,u]]}function b(t,r,a,o,e,i,u,h,f){if(0===f)return function(t,r){for(var a=0,o=t.length,e=0;o>e;e++)a+=n(t[e],r[e],t[(e+1)%o],r[(e+1)%o]);return a/2}([t,a,e,u],[r,o,i,h]);var c=m(t,r,a,o,e,i,u,h,.5),p=[].concat(c[0],[f-1]),s=[].concat(c[1],[f-1]);return b.apply(void 0,p)+b.apply(void 0,s)}var P={extrema:A,box:function(t,n,r,o,e,i,u,h){for(var f=[t,u],c=[n,h],p=A(t,r,e,u),s=A(n,o,i,h),v=0;p.length>v;v++)f.push(x(t,r,e,u,p[v]));for(var M=0;s.length>M;M++)c.push(x(n,o,i,h,s[M]));return a(f,c)},length:function(t,n,r,a,o,e,i,u){return b(t,n,r,a,o,e,i,u,3)},nearestPoint:function(t,n,r,a,o,e,i,u,h,f,c){return p([t,r,o,i],[n,a,e,u],h,f,x,c)},pointDistance:function(t,r,a,o,e,i,u,h,f,c,p){var s=this.nearestPoint(t,r,a,o,e,i,u,h,f,c,p);return n(s.x,s.y,f,c)},interpolationAt:x,pointAt:function(t,n,r,a,o,e,i,u,h){return{x:x(t,r,o,i,h),y:x(n,a,e,u,h)}},divide:function(t,n,r,a,o,e,i,u,h){return m(t,n,r,a,o,e,i,u,h)},tangentAngle:function(t,n,r,a,e,i,u,h,f){var c=d(t,r,e,u,f),p=d(n,a,i,h,f);return o(Math.atan2(p,c))}};function I(t,n){var r=Math.abs(t);return n>0?r:-1*r}var q=function(t,n,r,a,o,e){var i=r,u=a;if(0===i||0===u)return{x:t,y:n};for(var h=o-t,f=e-n,c=Math.abs(h),p=Math.abs(f),s=i*i,v=u*u,M=Math.PI/4,l=0,y=0,g=0;4>g;g++){l=i*Math.cos(M),y=u*Math.sin(M);var x=(s-v)*Math.pow(Math.cos(M),3)/i,d=(v-s)*Math.pow(Math.sin(M),3)/u,A=l-x,m=y-d,b=c-x,P=p-d,q=Math.hypot(m,A),D=Math.hypot(P,b);M=Math.min(Math.PI/2,Math.max(0,M+=q*Math.asin((A*P-m*b)/(q*D))/Math.sqrt(s+v-l*l-y*y)))}return{x:t+I(l,h),y:n+I(y,f)}};function D(t,n,r,a,o,e){return r*Math.cos(o)*Math.cos(e)-a*Math.sin(o)*Math.sin(e)+t}function L(t,n,r,a,o,e){return r*Math.sin(o)*Math.cos(e)+a*Math.cos(o)*Math.sin(e)+n}function _(t,n,r){return{x:t*Math.cos(r),y:n*Math.sin(r)}}function w(t,n,r){var a=Math.cos(r),o=Math.sin(r);return[t*a-n*o,t*o+n*a]}var B={box:function(t,n,r,a,o,e,i){for(var u=function(t,n,r){return Math.atan(-n/t*Math.tan(r))}(r,a,o),h=1/0,f=-1/0,c=[e,i],p=2*-Math.PI;2*Math.PI>=p;p+=Math.PI){var s=u+p;i>e?s>e&&i>s&&c.push(s):s>i&&e>s&&c.push(s)}for(var v=0;c.length>v;v++){var M=D(t,0,r,a,o,c[v]);h>M&&(h=M),M>f&&(f=M)}for(var l=function(t,n,r){return Math.atan(n/(t*Math.tan(r)))}(r,a,o),y=1/0,g=-1/0,x=[e,i],d=2*-Math.PI;2*Math.PI>=d;d+=Math.PI){var A=l+d;i>e?A>e&&i>A&&x.push(A):A>i&&e>A&&x.push(A)}for(var m=0;x.length>m;m++){var b=L(0,n,r,a,o,x[m]);y>b&&(y=b),b>g&&(g=b)}return{x:h,y:y,width:f-h,height:g-y}},length:function(t,n,r,a,o,e,i){},nearestPoint:function(t,n,r,a,o,e,i,u,h){var f=w(u-t,h-n,-o),c=q(0,0,r,a,f[0],f[1]),p=function(t,n,r,a){return(Math.atan2(a*t,r*n)+2*Math.PI)%(2*Math.PI)}(r,a,c.x,c.y);e>p?c=_(r,a,e):p>i&&(c=_(r,a,i));var s=w(c.x,c.y,o);return{x:s[0]+t,y:s[1]+n}},pointDistance:function(t,r,a,o,e,i,u,h,f){var c=this.nearestPoint(t,r,a,o,e,i,u,h,f);return n(c.x,c.y,h,f)},pointAt:function(t,n,r,a,o,e,i,u){var h=(i-e)*u+e;return{x:D(t,0,r,a,o,h),y:L(0,n,r,a,o,h)}},tangentAngle:function(t,n,r,a,e,i,u,h){var f=(u-i)*h+i,c=function(t,n,r,a,o,e,i,u){return-1*r*Math.cos(o)*Math.sin(u)-a*Math.sin(o)*Math.cos(u)}(0,0,r,a,e,0,0,f),p=function(t,n,r,a,o,e,i,u){return-1*r*Math.sin(o)*Math.sin(u)+a*Math.cos(o)*Math.cos(u)}(0,0,r,a,e,0,0,f);return o(Math.atan2(p,c))}};function T(t){for(var r=0,a=[],o=0;t.length-1>o;o++){var e=t[o],i=t[o+1],u=n(e[0],e[1],i[0],i[1]);a.push({from:e,to:i,length:u}),r+=u}return{segments:a,totalLength:r}}function j(t){if(2>t.length)return 0;for(var r=0,a=0;t.length-1>a;a++){var o=t[a],e=t[a+1];r+=n(o[0],o[1],e[0],e[1])}return r}function F(t,n){if(n>1||0>n||2>t.length)return null;var r=T(t),a=r.segments,o=r.totalLength;if(0===o)return{x:t[0][0],y:t[0][1]};for(var e=0,i=null,u=0;a.length>u;u++){var h=a[u],c=h.from,p=h.to,s=h.length/o;if(n>=e&&e+s>=n){i=f.pointAt(c[0],c[1],p[0],p[1],(n-e)/s);break}e+=s}return i}function G(t,n){if(n>1||0>n||2>t.length)return 0;for(var r=T(t),a=r.segments,o=r.totalLength,e=0,i=0,u=0;a.length>u;u++){var h=a[u],f=h.from,c=h.to,p=h.length/o;if(n>=e&&e+p>=n){i=Math.atan2(c[1]-f[1],c[0]-f[0]);break}e+=p}return i}function k(t,n,r){for(var a=1/0,o=0;t.length-1>o;o++){var e=t[o],i=t[o+1],u=f.pointDistance(e[0],e[1],i[0],i[1],n,r);a>u&&(a=u)}return a}var O={box:function(t){for(var n=[],r=[],o=0;t.length>o;o++){var e=t[o];n.push(e[0]),r.push(e[1])}return a(n,r)},length:function(t){return j(t)},pointAt:function(t,n){return F(t,n)},pointDistance:function(t,n,r){return k(t,n,r)},tangentAngle:function(t,n){return G(t,n)}};function X(t){var n=t.slice(0);return t.length&&n.push(t[0]),n}var Y={box:function(t){return O.box(t)},length:function(t){return j(X(t))},pointAt:function(t,n){return F(X(t),n)},pointDistance:function(t,n,r){return k(X(t),n,r)},tangentAngle:function(t,n){return G(X(t),n)}};t.Arc=B,t.Cubic=P,t.Line=f,t.Polygon=Y,t.Polyline=O,t.Quad=g,t.Util=e,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.Math={}))}(this,(function(t){"use strict";function n(t,n,r,a){var o=t-r,e=n-a;return Math.sqrt(o*o+e*e)}function r(t,n){return.001>Math.abs(t-n)}function a(t,n){var r=Math.min.apply(Math,t),a=Math.min.apply(Math,n);return{x:r,y:a,width:Math.max.apply(Math,t)-r,height:Math.max.apply(Math,n)-a}}function o(t){return(t+2*Math.PI)%(2*Math.PI)}var e=Object.freeze({__proto__:null,distance:n,isNumberEqual:r,getBBoxByArray:a,getBBoxRange:function(t,n,r,a){return{minX:Math.min(t,r),maxX:Math.max(t,r),minY:Math.min(n,a),maxY:Math.max(n,a)}},piMod:o}),i="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var t=0,n=arguments.length;n--;)t+=arguments[n]*arguments[n];return Math.sqrt(t)});u=new i(2),i!=Float32Array&&(u[0]=0,u[1]=0),h=u;var u,h,f={box:function(t,n,r,o){return a([t,r],[n,o])},length:function(t,r,a,o){return n(t,r,a,o)},pointAt:function(t,n,r,a,o){return{x:(1-o)*t+o*r,y:(1-o)*n+o*a}},pointDistance:function(t,r,a,o,e,i){var u=(a-t)*(e-t)+(o-r)*(i-r);return 0>u?n(t,r,e,i):u>(a-t)*(a-t)+(o-r)*(o-r)?n(a,o,e,i):this.pointToLine(t,r,a,o,e,i)},pointToLine:function(t,n,r,a,o,e){var i=[r-t,a-n];if(function(t,n){return t[0]===n[0]&&t[1]===n[1]}(i,[0,0]))return Math.sqrt((o-t)*(o-t)+(e-n)*(e-n));var u=[-i[1],i[0]];return function(t,n){var r=n[0],a=n[1],o=r*r+a*a;o>0&&(o=1/Math.sqrt(o)),t[0]=n[0]*o,t[1]=n[1]*o}(u,u),Math.abs(function(t,n){return t[0]*n[0]+t[1]*n[1]}([o-t,e-n],u))},tangentAngle:function(t,n,r,a){return Math.atan2(a-n,r-t)}};function c(t,r,a,o,e,i){var u=-1,h=1/0,f=[a,o],c=20;i&&i>200&&(c=i/10);for(var p=1/c,s=p/10,v=0;c>=v;v++){var M=v*p,l=[e.apply(void 0,t.concat([M])),e.apply(void 0,r.concat([M]))],y=n(f[0],f[1],l[0],l[1]);h>y&&(u=M,h=y)}if(0===u)return{x:t[0],y:r[0]};if(1===u){var g=t.length;return{x:t[g-1],y:r[g-1]}}h=1/0;for(var x=0;32>x&&1e-4<=s;x++){var d=u-s,A=u+s,m=[e.apply(void 0,t.concat([d])),e.apply(void 0,r.concat([d]))],b=n(f[0],f[1],m[0],m[1]);if(d>=0&&h>b)u=d,h=b;else{var P=[e.apply(void 0,t.concat([A])),e.apply(void 0,r.concat([A]))],I=n(f[0],f[1],P[0],P[1]);1>=A&&h>I?(u=A,h=I):s*=.5}}return{x:e.apply(void 0,t.concat([u])),y:e.apply(void 0,r.concat([u]))}}function p(t,n,r,a){var o=1-a;return o*o*t+2*a*o*n+a*a*r}function s(t,n,a){var o=t+a-2*n;if(r(o,0))return[.5];var e=(t-n)/o;return e>1||0>e?[]:[e]}function v(t,n,r,a){return 2*(1-a)*(n-t)+2*a*(r-n)}function M(t,n,r,a,o,e,i){var u=p(t,r,o,i),h=p(n,a,e,i),c=f.pointAt(t,n,r,a,i),s=f.pointAt(r,a,o,e,i);return[[t,n,c.x,c.y,u,h],[u,h,s.x,s.y,o,e]]}function l(t,r,a,o,e,i,u){if(0===u)return(n(t,r,a,o)+n(a,o,e,i)+n(t,r,e,i))/2;var h=M(t,r,a,o,e,i,.5),f=h[0],c=h[1];return f.push(u-1),c.push(u-1),l.apply(void 0,f)+l.apply(void 0,c)}var y={box:function(t,n,r,o,e,i){var u=s(t,r,e)[0],h=s(n,o,i)[0],f=[t,e],c=[n,i];return void 0!==u&&f.push(p(t,r,e,u)),void 0!==h&&c.push(p(n,o,i,h)),a(f,c)},length:function(t,n,r,a,o,e){return l(t,n,r,a,o,e,3)},nearestPoint:function(t,n,r,a,o,e,i,u){return c([t,r,o],[n,a,e],i,u,p)},pointDistance:function(t,r,a,o,e,i,u,h){var f=this.nearestPoint(t,r,a,o,e,i,u,h);return n(f.x,f.y,u,h)},interpolationAt:p,pointAt:function(t,n,r,a,o,e,i){return{x:p(t,r,o,i),y:p(n,a,e,i)}},divide:function(t,n,r,a,o,e,i){return M(t,n,r,a,o,e,i)},tangentAngle:function(t,n,r,a,e,i,u){var h=v(t,r,e,u),f=v(n,a,i,u);return o(Math.atan2(f,h))}};function g(t,n,r,a,o){var e=1-o;return e*e*e*t+3*n*o*e*e+3*r*o*o*e+a*o*o*o}function x(t,n,r,a,o){var e=1-o;return 3*(e*e*(n-t)+2*e*o*(r-n)+o*o*(a-r))}function d(t,n,a,o){var e,i,u,h=-3*t+9*n-9*a+3*o,f=6*t-12*n+6*a,c=3*n-3*t,p=[];if(r(h,0))r(f,0)||0>(e=-c/f)||e>1||p.push(e);else{var s=f*f-4*h*c;r(s,0)?p.push(-f/(2*h)):s>0&&(i=(-f-(u=Math.sqrt(s)))/(2*h),0>(e=(-f+u)/(2*h))||e>1||p.push(e),0>i||i>1||p.push(i))}return p}function A(t,n,r,a,o,e,i,u,h){var c=g(t,r,o,i,h),p=g(n,a,e,u,h),s=f.pointAt(t,n,r,a,h),v=f.pointAt(r,a,o,e,h),M=f.pointAt(o,e,i,u,h),l=f.pointAt(s.x,s.y,v.x,v.y,h),y=f.pointAt(v.x,v.y,M.x,M.y,h);return[[t,n,s.x,s.y,l.x,l.y,c,p],[c,p,y.x,y.y,M.x,M.y,i,u]]}function m(t,r,a,o,e,i,u,h,f){if(0===f)return function(t,r){for(var a=0,o=t.length,e=0;o>e;e++)a+=n(t[e],r[e],t[(e+1)%o],r[(e+1)%o]);return a/2}([t,a,e,u],[r,o,i,h]);var c=A(t,r,a,o,e,i,u,h,.5),p=[].concat(c[0],[f-1]),s=[].concat(c[1],[f-1]);return m.apply(void 0,p)+m.apply(void 0,s)}var b={extrema:d,box:function(t,n,r,o,e,i,u,h){for(var f=[t,u],c=[n,h],p=d(t,r,e,u),s=d(n,o,i,h),v=0;p.length>v;v++)f.push(g(t,r,e,u,p[v]));for(var M=0;s.length>M;M++)c.push(g(n,o,i,h,s[M]));return a(f,c)},length:function(t,n,r,a,o,e,i,u){return m(t,n,r,a,o,e,i,u,3)},nearestPoint:function(t,n,r,a,o,e,i,u,h,f,p){return c([t,r,o,i],[n,a,e,u],h,f,g,p)},pointDistance:function(t,r,a,o,e,i,u,h,f,c,p){var s=this.nearestPoint(t,r,a,o,e,i,u,h,f,c,p);return n(s.x,s.y,f,c)},interpolationAt:g,pointAt:function(t,n,r,a,o,e,i,u,h){return{x:g(t,r,o,i,h),y:g(n,a,e,u,h)}},divide:function(t,n,r,a,o,e,i,u,h){return A(t,n,r,a,o,e,i,u,h)},tangentAngle:function(t,n,r,a,e,i,u,h,f){var c=x(t,r,e,u,f),p=x(n,a,i,h,f);return o(Math.atan2(p,c))}};function P(t,n){var r=Math.abs(t);return n>0?r:-1*r}var I=function(t,n,r,a,o,e){var i=r,u=a;if(0===i||0===u)return{x:t,y:n};for(var h=o-t,f=e-n,c=Math.abs(h),p=Math.abs(f),s=i*i,v=u*u,M=Math.PI/4,l=0,y=0,g=0;4>g;g++){l=i*Math.cos(M),y=u*Math.sin(M);var x=(s-v)*Math.pow(Math.cos(M),3)/i,d=(v-s)*Math.pow(Math.sin(M),3)/u,A=l-x,m=y-d,b=c-x,I=p-d,q=Math.hypot(m,A),D=Math.hypot(I,b);M=Math.min(Math.PI/2,Math.max(0,M+=q*Math.asin((A*I-m*b)/(q*D))/Math.sqrt(s+v-l*l-y*y)))}return{x:t+P(l,h),y:n+P(y,f)}};function q(t,n,r,a,o,e){return r*Math.cos(o)*Math.cos(e)-a*Math.sin(o)*Math.sin(e)+t}function D(t,n,r,a,o,e){return r*Math.sin(o)*Math.cos(e)+a*Math.cos(o)*Math.sin(e)+n}function L(t,n,r){return{x:t*Math.cos(r),y:n*Math.sin(r)}}function _(t,n,r){var a=Math.cos(r),o=Math.sin(r);return[t*a-n*o,t*o+n*a]}var w={box:function(t,n,r,a,o,e,i){for(var u=function(t,n,r){return Math.atan(-n/t*Math.tan(r))}(r,a,o),h=1/0,f=-1/0,c=[e,i],p=2*-Math.PI;2*Math.PI>=p;p+=Math.PI){var s=u+p;i>e?s>e&&i>s&&c.push(s):s>i&&e>s&&c.push(s)}for(var v=0;c.length>v;v++){var M=q(t,0,r,a,o,c[v]);h>M&&(h=M),M>f&&(f=M)}for(var l=function(t,n,r){return Math.atan(n/(t*Math.tan(r)))}(r,a,o),y=1/0,g=-1/0,x=[e,i],d=2*-Math.PI;2*Math.PI>=d;d+=Math.PI){var A=l+d;i>e?A>e&&i>A&&x.push(A):A>i&&e>A&&x.push(A)}for(var m=0;x.length>m;m++){var b=D(0,n,r,a,o,x[m]);y>b&&(y=b),b>g&&(g=b)}return{x:h,y:y,width:f-h,height:g-y}},length:function(t,n,r,a,o,e,i){},nearestPoint:function(t,n,r,a,o,e,i,u,h){var f=_(u-t,h-n,-o),c=I(0,0,r,a,f[0],f[1]),p=function(t,n,r,a){return(Math.atan2(a*t,r*n)+2*Math.PI)%(2*Math.PI)}(r,a,c.x,c.y);e>p?c=L(r,a,e):p>i&&(c=L(r,a,i));var s=_(c.x,c.y,o);return{x:s[0]+t,y:s[1]+n}},pointDistance:function(t,r,a,o,e,i,u,h,f){var c=this.nearestPoint(t,r,a,o,e,i,u,h,f);return n(c.x,c.y,h,f)},pointAt:function(t,n,r,a,o,e,i,u){var h=(i-e)*u+e;return{x:q(t,0,r,a,o,h),y:D(0,n,r,a,o,h)}},tangentAngle:function(t,n,r,a,e,i,u,h){var f=(u-i)*h+i,c=function(t,n,r,a,o,e,i,u){return-1*r*Math.cos(o)*Math.sin(u)-a*Math.sin(o)*Math.cos(u)}(0,0,r,a,e,0,0,f),p=function(t,n,r,a,o,e,i,u){return-1*r*Math.sin(o)*Math.sin(u)+a*Math.cos(o)*Math.cos(u)}(0,0,r,a,e,0,0,f);return o(Math.atan2(p,c))}};function B(t){for(var r=0,a=[],o=0;t.length-1>o;o++){var e=t[o],i=t[o+1],u=n(e[0],e[1],i[0],i[1]);a.push({from:e,to:i,length:u}),r+=u}return{segments:a,totalLength:r}}function T(t){if(2>t.length)return 0;for(var r=0,a=0;t.length-1>a;a++){var o=t[a],e=t[a+1];r+=n(o[0],o[1],e[0],e[1])}return r}function j(t,n){if(n>1||0>n||2>t.length)return null;var r=B(t),a=r.segments,o=r.totalLength;if(0===o)return{x:t[0][0],y:t[0][1]};for(var e=0,i=null,u=0;a.length>u;u++){var h=a[u],c=h.from,p=h.to,s=h.length/o;if(n>=e&&e+s>=n){i=f.pointAt(c[0],c[1],p[0],p[1],(n-e)/s);break}e+=s}return i}function F(t,n){if(n>1||0>n||2>t.length)return 0;for(var r=B(t),a=r.segments,o=r.totalLength,e=0,i=0,u=0;a.length>u;u++){var h=a[u],f=h.from,c=h.to,p=h.length/o;if(n>=e&&e+p>=n){i=Math.atan2(c[1]-f[1],c[0]-f[0]);break}e+=p}return i}function G(t,n,r){for(var a=1/0,o=0;t.length-1>o;o++){var e=t[o],i=t[o+1],u=f.pointDistance(e[0],e[1],i[0],i[1],n,r);a>u&&(a=u)}return a}var k={box:function(t){for(var n=[],r=[],o=0;t.length>o;o++){var e=t[o];n.push(e[0]),r.push(e[1])}return a(n,r)},length:function(t){return T(t)},pointAt:function(t,n){return j(t,n)},pointDistance:function(t,n,r){return G(t,n,r)},tangentAngle:function(t,n){return F(t,n)}};function O(t){var n=t.slice(0);return t.length&&n.push(t[0]),n}var X={box:function(t){return k.box(t)},length:function(t){return T(O(t))},pointAt:function(t,n){return j(O(t),n)},pointDistance:function(t,n,r){return G(O(t),n,r)},tangentAngle:function(t,n){return F(O(t),n)}};t.Arc=w,t.Cubic=b,t.Line=f,t.Polygon=X,t.Polyline=k,t.Quad=y,t.Util=e,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@antv/g-math", | ||
"version": "1.7.44", | ||
"version": "1.7.45", | ||
"description": "Geometry util", | ||
@@ -42,3 +42,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "24512ba8af869f3ce8318f746fc635fb2aab13e0" | ||
"gitHead": "620a506129c9037698a374244778bb26a1c4202b" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136759