@antv/g-math 1.0.19-alpha.2 → 1.0.20-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.min.js +1 -1
- package/es/util.js +9 -9
- package/lib/util.js +9 -9
- package/package.json +2 -3
package/dist/index.umd.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Math=t():(n.G=n.G||{},n.G.Math=t())}(window,(function(){return function(n){var t={};function r(e){if(t[e])return t[e].exports;var u=t[e]={i:e,l:!1,exports:{}};return n[e].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=n,r.c=t,r.d=function(n,t,e){r.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:e})},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,t){if(1&t&&(n=r(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var u in n)r.d(e,u,function(t){return n[t]}.bind(null,u));return e},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.p="",r(r.s=10)}({0:function(n,t,r){"use strict";(function(n){var r="object"==typeof n&&n&&n.Object===Object&&n;t.a=r}).call(this,r(9))},10:function(n,t,r){"use strict";r.r(t),r.d(t,"Quad",(function(){return _n})),r.d(t,"Cubic",(function(){return kn})),r.d(t,"Arc",(function(){return Rn})),r.d(t,"Line",(function(){return qn})),r.d(t,"Polygon",(function(){return nt})),r.d(t,"Polyline",(function(){return Zn})),r.d(t,"Util",(function(){return e}));var e={};r.r(e),r.d(e,"distance",(function(){return q})),r.d(e,"isNumberEqual",(function(){return I})),r.d(e,"getBBoxByArray",(function(){return S})),r.d(e,"getBBoxRange",(function(){return D})),r.d(e,"piMod",(function(){return L}));var u={};r.r(u),r.d(u,"create",(function(){return B})),r.d(u,"clone",(function(){return F})),r.d(u,"fromValues",(function(){return E})),r.d(u,"copy",(function(){return z})),r.d(u,"set",(function(){return G})),r.d(u,"add",(function(){return k})),r.d(u,"subtract",(function(){return N})),r.d(u,"multiply",(function(){return U})),r.d(u,"divide",(function(){return X})),r.d(u,"ceil",(function(){return Y})),r.d(u,"floor",(function(){return C})),r.d(u,"min",(function(){return Q})),r.d(u,"max",(function(){return R})),r.d(u,"round",(function(){return V})),r.d(u,"scale",(function(){return H})),r.d(u,"scaleAndAdd",(function(){return J})),r.d(u,"distance",(function(){return K})),r.d(u,"squaredDistance",(function(){return W})),r.d(u,"length",(function(){return Z})),r.d(u,"squaredLength",(function(){return $})),r.d(u,"negate",(function(){return nn})),r.d(u,"inverse",(function(){return tn})),r.d(u,"normalize",(function(){return rn})),r.d(u,"dot",(function(){return en})),r.d(u,"cross",(function(){return un})),r.d(u,"lerp",(function(){return on})),r.d(u,"random",(function(){return an})),r.d(u,"transformMat2",(function(){return cn})),r.d(u,"transformMat2d",(function(){return fn})),r.d(u,"transformMat3",(function(){return hn})),r.d(u,"transformMat4",(function(){return ln})),r.d(u,"rotate",(function(){return sn})),r.d(u,"angle",(function(){return vn})),r.d(u,"zero",(function(){return dn})),r.d(u,"str",(function(){return pn})),r.d(u,"exactEquals",(function(){return Mn})),r.d(u,"equals",(function(){return yn})),r.d(u,"len",(function(){return bn})),r.d(u,"sub",(function(){return xn})),r.d(u,"mul",(function(){return mn})),r.d(u,"div",(function(){return An})),r.d(u,"dist",(function(){return Pn})),r.d(u,"sqrDist",(function(){return jn})),r.d(u,"sqrLen",(function(){return wn})),r.d(u,"forEach",(function(){return On}));Object.create;function o(n,t){var r="function"==typeof Symbol&&n[Symbol.iterator];if(!r)return n;var e,u,o=r.call(n),a=[];try{for(;(void 0===t||t-- >0)&&!(e=o.next()).done;)a.push(e.value)}catch(n){u={error:n}}finally{try{e&&!e.done&&(r=o.return)&&r.call(o)}finally{if(u)throw u.error}}return a}function a(n,t,r){if(r||2===arguments.length)for(var e,u=0,o=t.length;u<o;u++)!e&&u in t||(e||(e=Array.prototype.slice.call(t,0,u)),e[u]=t[u]);return n.concat(e||Array.prototype.slice.call(t))}Object.create;var i=r(0),c="object"==typeof self&&self&&self.Object===Object&&self,f=(i.a||c||Function("return this")()).Symbol,h=Object.prototype,l=h.hasOwnProperty,s=h.toString,v=f?f.toStringTag:void 0;var d=function(n){var t=l.call(n,v),r=n[v];try{n[v]=void 0;var e=!0}catch(n){}var u=s.call(n);return e&&(t?n[v]=r:delete n[v]),u},p=Object.prototype.toString;var M=function(n){return p.call(n)},y=f?f.toStringTag:void 0;var g=function(n){return null==n?void 0===n?"[object Undefined]":"[object Null]":y&&y in Object(n)?d(n):M(n)};var b=function(n){return null!=n&&"object"==typeof n};var x=function(n){return"symbol"==typeof n||b(n)&&"[object Symbol]"==g(n)};var m=function(n,t,r){for(var e=-1,u=n.length;++e<u;){var o=n[e],a=t(o);if(null!=a&&(void 0===i?a==a&&!x(a):r(a,i)))var i=a,c=o}return c};var A=function(n,t){return n<t};var P=function(n){return n};var j=function(n){return n&&n.length?m(n,P,A):void 0};var w=function(n,t){return n>t};var O=function(n){return n&&n.length?m(n,P,w):void 0};function q(n,t,r,e){var u=n-r,o=t-e;return Math.sqrt(u*u+o*o)}function I(n,t){return Math.abs(n-t)<.001}function S(n,t){var r=j(n),e=j(t);return{x:r,y:e,width:O(n)-r,height:O(t)-e}}function D(n,t,r,e){return{minX:j([n,r]),maxX:O([n,r]),minY:j([t,e]),maxY:O([t,e])}}function L(n){return(n+2*Math.PI)%(2*Math.PI)}var T="undefined"!=typeof Float32Array?Float32Array:Array,_=Math.random;Math.PI;function B(){var n=new T(2);return T!=Float32Array&&(n[0]=0,n[1]=0),n}function F(n){var t=new T(2);return t[0]=n[0],t[1]=n[1],t}function E(n,t){var r=new T(2);return r[0]=n,r[1]=t,r}function z(n,t){return n[0]=t[0],n[1]=t[1],n}function G(n,t,r){return n[0]=t,n[1]=r,n}function k(n,t,r){return n[0]=t[0]+r[0],n[1]=t[1]+r[1],n}function N(n,t,r){return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n}function U(n,t,r){return n[0]=t[0]*r[0],n[1]=t[1]*r[1],n}function X(n,t,r){return n[0]=t[0]/r[0],n[1]=t[1]/r[1],n}function Y(n,t){return n[0]=Math.ceil(t[0]),n[1]=Math.ceil(t[1]),n}function C(n,t){return n[0]=Math.floor(t[0]),n[1]=Math.floor(t[1]),n}function Q(n,t,r){return n[0]=Math.min(t[0],r[0]),n[1]=Math.min(t[1],r[1]),n}function R(n,t,r){return n[0]=Math.max(t[0],r[0]),n[1]=Math.max(t[1],r[1]),n}function V(n,t){return n[0]=Math.round(t[0]),n[1]=Math.round(t[1]),n}function H(n,t,r){return n[0]=t[0]*r,n[1]=t[1]*r,n}function J(n,t,r,e){return n[0]=t[0]+r[0]*e,n[1]=t[1]+r[1]*e,n}function K(n,t){var r=t[0]-n[0],e=t[1]-n[1];return Math.hypot(r,e)}function W(n,t){var r=t[0]-n[0],e=t[1]-n[1];return r*r+e*e}function Z(n){var t=n[0],r=n[1];return Math.hypot(t,r)}function $(n){var t=n[0],r=n[1];return t*t+r*r}function nn(n,t){return n[0]=-t[0],n[1]=-t[1],n}function tn(n,t){return n[0]=1/t[0],n[1]=1/t[1],n}function rn(n,t){var r=t[0],e=t[1],u=r*r+e*e;return u>0&&(u=1/Math.sqrt(u)),n[0]=t[0]*u,n[1]=t[1]*u,n}function en(n,t){return n[0]*t[0]+n[1]*t[1]}function un(n,t,r){var e=t[0]*r[1]-t[1]*r[0];return n[0]=n[1]=0,n[2]=e,n}function on(n,t,r,e){var u=t[0],o=t[1];return n[0]=u+e*(r[0]-u),n[1]=o+e*(r[1]-o),n}function an(n,t){t=t||1;var r=2*_()*Math.PI;return n[0]=Math.cos(r)*t,n[1]=Math.sin(r)*t,n}function cn(n,t,r){var e=t[0],u=t[1];return n[0]=r[0]*e+r[2]*u,n[1]=r[1]*e+r[3]*u,n}function fn(n,t,r){var e=t[0],u=t[1];return n[0]=r[0]*e+r[2]*u+r[4],n[1]=r[1]*e+r[3]*u+r[5],n}function hn(n,t,r){var e=t[0],u=t[1];return n[0]=r[0]*e+r[3]*u+r[6],n[1]=r[1]*e+r[4]*u+r[7],n}function ln(n,t,r){var e=t[0],u=t[1];return n[0]=r[0]*e+r[4]*u+r[12],n[1]=r[1]*e+r[5]*u+r[13],n}function sn(n,t,r,e){var u=t[0]-r[0],o=t[1]-r[1],a=Math.sin(e),i=Math.cos(e);return n[0]=u*i-o*a+r[0],n[1]=u*a+o*i+r[1],n}function vn(n,t){var r=n[0],e=n[1],u=t[0],o=t[1],a=Math.sqrt(r*r+e*e)*Math.sqrt(u*u+o*o),i=a&&(r*u+e*o)/a;return Math.acos(Math.min(Math.max(i,-1),1))}function dn(n){return n[0]=0,n[1]=0,n}function pn(n){return"vec2("+n[0]+", "+n[1]+")"}function Mn(n,t){return n[0]===t[0]&&n[1]===t[1]}function yn(n,t){var r=n[0],e=n[1],u=t[0],o=t[1];return Math.abs(r-u)<=1e-6*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(e-o)<=1e-6*Math.max(1,Math.abs(e),Math.abs(o))}Math.hypot||(Math.hypot=function(){for(var n=0,t=arguments.length;t--;)n+=arguments[t]*arguments[t];return Math.sqrt(n)});var gn,bn=Z,xn=N,mn=U,An=X,Pn=K,jn=W,wn=$,On=(gn=B(),function(n,t,r,e,u,o){var a,i;for(t||(t=2),r||(r=0),i=e?Math.min(e*t+r,n.length):n.length,a=r;a<i;a+=t)gn[0]=n[a],gn[1]=n[a+1],u(gn,gn,o),n[a]=gn[0],n[a+1]=gn[1];return n}),qn={box:function(n,t,r,e){return S([n,r],[t,e])},length:function(n,t,r,e){return q(n,t,r,e)},pointAt:function(n,t,r,e,u){return{x:(1-u)*n+u*r,y:(1-u)*t+u*e}},pointDistance:function(n,t,r,e,u,o){var a=(r-n)*(u-n)+(e-t)*(o-t);return a<0?q(n,t,u,o):a>(r-n)*(r-n)+(e-t)*(e-t)?q(r,e,u,o):this.pointToLine(n,t,r,e,u,o)},pointToLine:function(n,t,r,e,o,a){var i=[r-n,e-t];if(u.exactEquals(i,[0,0]))return Math.sqrt((o-n)*(o-n)+(a-t)*(a-t));var c=[-i[1],i[0]];u.normalize(c,c);var f=[o-n,a-t];return Math.abs(u.dot(f,c))},tangentAngle:function(n,t,r,e){return Math.atan2(e-t,r-n)}};function In(n,t,r,e,u,i){var c=-1,f=1/0,h=[r,e],l=20;i&&i>200&&(l=i/10);for(var s=1/l,v=s/10,d=0;d<=l;d++){var p=d*s,M=[u.apply(void 0,a([],o(n.concat([p])),!1)),u.apply(void 0,a([],o(t.concat([p])),!1))];(x=q(h[0],h[1],M[0],M[1]))<f&&(c=p,f=x)}if(0===c)return{x:n[0],y:t[0]};if(1===c){var y=n.length;return{x:n[y-1],y:t[y-1]}}f=1/0;for(d=0;d<32&&!(v<1e-4);d++){var g=c-v,b=c+v,x=(M=[u.apply(void 0,a([],o(n.concat([g])),!1)),u.apply(void 0,a([],o(t.concat([g])),!1))],q(h[0],h[1],M[0],M[1]));if(g>=0&&x<f)c=g,f=x;else{var m=[u.apply(void 0,a([],o(n.concat([b])),!1)),u.apply(void 0,a([],o(t.concat([b])),!1))],A=q(h[0],h[1],m[0],m[1]);b<=1&&A<f?(c=b,f=A):v*=.5}}return{x:u.apply(void 0,a([],o(n.concat([c])),!1)),y:u.apply(void 0,a([],o(t.concat([c])),!1))}}function Sn(n,t,r,e){var u=1-e;return u*u*n+2*e*u*t+e*e*r}function Dn(n,t,r){var e=n+r-2*t;if(I(e,0))return[.5];var u=(n-t)/e;return u<=1&&u>=0?[u]:[]}function Ln(n,t,r,e){return 2*(1-e)*(t-n)+2*e*(r-t)}function Tn(n,t,r,e,u,o,a){var i=Sn(n,r,u,a),c=Sn(t,e,o,a),f=qn.pointAt(n,t,r,e,a),h=qn.pointAt(r,e,u,o,a);return[[n,t,f.x,f.y,i,c],[i,c,h.x,h.y,u,o]]}var _n={box:function(n,t,r,e,u,o){var a=Dn(n,r,u)[0],i=Dn(t,e,o)[0],c=[n,u],f=[t,o];return void 0!==a&&c.push(Sn(n,r,u,a)),void 0!==i&&f.push(Sn(t,e,o,i)),S(c,f)},length:function(n,t,r,e,u,i){return function n(t,r,e,u,i,c,f){if(0===f)return(q(t,r,e,u)+q(e,u,i,c)+q(t,r,i,c))/2;var h=Tn(t,r,e,u,i,c,.5),l=h[0],s=h[1];return l.push(f-1),s.push(f-1),n.apply(void 0,a([],o(l),!1))+n.apply(void 0,a([],o(s),!1))}(n,t,r,e,u,i,3)},nearestPoint:function(n,t,r,e,u,o,a,i){return In([n,r,u],[t,e,o],a,i,Sn)},pointDistance:function(n,t,r,e,u,o,a,i){var c=this.nearestPoint(n,t,r,e,u,o,a,i);return q(c.x,c.y,a,i)},interpolationAt:Sn,pointAt:function(n,t,r,e,u,o,a){return{x:Sn(n,r,u,a),y:Sn(t,e,o,a)}},divide:function(n,t,r,e,u,o,a){return Tn(n,t,r,e,u,o,a)},tangentAngle:function(n,t,r,e,u,o,a){var i=Ln(n,r,u,a),c=Ln(t,e,o,a);return L(Math.atan2(c,i))}};function Bn(n,t,r,e,u){var o=1-u;return o*o*o*n+3*t*u*o*o+3*r*u*u*o+e*u*u*u}function Fn(n,t,r,e,u){var o=1-u;return 3*(o*o*(t-n)+2*o*u*(r-t)+u*u*(e-r))}function En(n,t,r,e){var u,o,a,i=-3*n+9*t-9*r+3*e,c=6*n-12*t+6*r,f=3*t-3*n,h=[];if(I(i,0))I(c,0)||(u=-f/c)>=0&&u<=1&&h.push(u);else{var l=c*c-4*i*f;I(l,0)?h.push(-c/(2*i)):l>0&&(o=(-c-(a=Math.sqrt(l)))/(2*i),(u=(-c+a)/(2*i))>=0&&u<=1&&h.push(u),o>=0&&o<=1&&h.push(o))}return h}function zn(n,t,r,e,u,o,a,i,c){var f=Bn(n,r,u,a,c),h=Bn(t,e,o,i,c),l=qn.pointAt(n,t,r,e,c),s=qn.pointAt(r,e,u,o,c),v=qn.pointAt(u,o,a,i,c),d=qn.pointAt(l.x,l.y,s.x,s.y,c),p=qn.pointAt(s.x,s.y,v.x,v.y,c);return[[n,t,l.x,l.y,d.x,d.y,f,h],[f,h,p.x,p.y,v.x,v.y,a,i]]}function Gn(n,t,r,e,u,i,c,f,h){if(0===h)return function(n,t){for(var r=0,e=n.length,u=0;u<e;u++){r+=q(n[u],t[u],n[(u+1)%e],t[(u+1)%e])}return r/2}([n,r,u,c],[t,e,i,f]);var l=zn(n,t,r,e,u,i,c,f,.5),s=a(a([],o(l[0]),!1),[h-1],!1),v=a(a([],o(l[1]),!1),[h-1],!1);return Gn.apply(void 0,a([],o(s),!1))+Gn.apply(void 0,a([],o(v),!1))}var kn={extrema:En,box:function(n,t,r,e,u,o,a,i){for(var c=[n,a],f=[t,i],h=En(n,r,u,a),l=En(t,e,o,i),s=0;s<h.length;s++)c.push(Bn(n,r,u,a,h[s]));for(s=0;s<l.length;s++)f.push(Bn(t,e,o,i,l[s]));return S(c,f)},length:function(n,t,r,e,u,o,a,i){return Gn(n,t,r,e,u,o,a,i,3)},nearestPoint:function(n,t,r,e,u,o,a,i,c,f,h){return In([n,r,u,a],[t,e,o,i],c,f,Bn,h)},pointDistance:function(n,t,r,e,u,o,a,i,c,f,h){var l=this.nearestPoint(n,t,r,e,u,o,a,i,c,f,h);return q(l.x,l.y,c,f)},interpolationAt:Bn,pointAt:function(n,t,r,e,u,o,a,i,c){return{x:Bn(n,r,u,a,c),y:Bn(t,e,o,i,c)}},divide:function(n,t,r,e,u,o,a,i,c){return zn(n,t,r,e,u,o,a,i,c)},tangentAngle:function(n,t,r,e,u,o,a,i,c){var f=Fn(n,r,u,a,c),h=Fn(t,e,o,i,c);return L(Math.atan2(h,f))}};function Nn(n,t){var r=Math.abs(n);return t>0?r:-1*r}var Un=function(n,t,r,e,u,o){var a=r,i=e;if(0===a||0===i)return{x:n,y:t};for(var c=u-n,f=o-t,h=Math.abs(c),l=Math.abs(f),s=a*a,v=i*i,d=Math.PI/4,p=0,M=0,y=0;y<4;y++){p=a*Math.cos(d),M=i*Math.sin(d);var g=(s-v)*Math.pow(Math.cos(d),3)/a,b=(v-s)*Math.pow(Math.sin(d),3)/i,x=p-g,m=M-b,A=h-g,P=l-b,j=Math.hypot(m,x),w=Math.hypot(P,A);d+=j*Math.asin((x*P-m*A)/(j*w))/Math.sqrt(s+v-p*p-M*M),d=Math.min(Math.PI/2,Math.max(0,d))}return{x:n+Nn(p,c),y:t+Nn(M,f)}};function Xn(n,t,r,e,u,o){return r*Math.cos(u)*Math.cos(o)-e*Math.sin(u)*Math.sin(o)+n}function Yn(n,t,r,e,u,o){return r*Math.sin(u)*Math.cos(o)+e*Math.cos(u)*Math.sin(o)+t}function Cn(n,t,r){return{x:n*Math.cos(r),y:t*Math.sin(r)}}function Qn(n,t,r){var e=Math.cos(r),u=Math.sin(r);return[n*e-t*u,n*u+t*e]}var Rn={box:function(n,t,r,e,u,o,a){for(var i=function(n,t,r){return Math.atan(-t/n*Math.tan(r))}(r,e,u),c=1/0,f=-1/0,h=[o,a],l=2*-Math.PI;l<=2*Math.PI;l+=Math.PI){var s=i+l;o<a?o<s&&s<a&&h.push(s):a<s&&s<o&&h.push(s)}for(l=0;l<h.length;l++){var v=Xn(n,0,r,e,u,h[l]);v<c&&(c=v),v>f&&(f=v)}var d=function(n,t,r){return Math.atan(t/(n*Math.tan(r)))}(r,e,u),p=1/0,M=-1/0,y=[o,a];for(l=2*-Math.PI;l<=2*Math.PI;l+=Math.PI){var g=d+l;o<a?o<g&&g<a&&y.push(g):a<g&&g<o&&y.push(g)}for(l=0;l<y.length;l++){var b=Yn(0,t,r,e,u,y[l]);b<p&&(p=b),b>M&&(M=b)}return{x:c,y:p,width:f-c,height:M-p}},length:function(n,t,r,e,u,o,a){},nearestPoint:function(n,t,r,e,u,a,i,c,f){var h=o(Qn(c-n,f-t,-u),2),l=h[0],s=h[1],v=Un(0,0,r,e,l,s),d=function(n,t,r,e){return(Math.atan2(e*n,r*t)+2*Math.PI)%(2*Math.PI)}(r,e,v.x,v.y);d<a?v=Cn(r,e,a):d>i&&(v=Cn(r,e,i));var p=Qn(v.x,v.y,u);return{x:p[0]+n,y:p[1]+t}},pointDistance:function(n,t,r,e,u,o,a,i,c){var f=this.nearestPoint(n,t,r,e,u,o,a,i,c);return q(f.x,f.y,i,c)},pointAt:function(n,t,r,e,u,o,a,i){var c=(a-o)*i+o;return{x:Xn(n,0,r,e,u,c),y:Yn(0,t,r,e,u,c)}},tangentAngle:function(n,t,r,e,u,o,a,i){var c=(a-o)*i+o,f=function(n,t,r,e,u,o,a,i){return-1*r*Math.cos(u)*Math.sin(i)-e*Math.sin(u)*Math.cos(i)}(0,0,r,e,u,0,0,c),h=function(n,t,r,e,u,o,a,i){return-1*r*Math.sin(u)*Math.sin(i)+e*Math.cos(u)*Math.cos(i)}(0,0,r,e,u,0,0,c);return L(Math.atan2(h,f))}};function Vn(n){for(var t=0,r=[],e=0;e<n.length-1;e++){var u=n[e],o=n[e+1],a=q(u[0],u[1],o[0],o[1]),i={from:u,to:o,length:a};r.push(i),t+=a}return{segments:r,totalLength:t}}function Hn(n){if(n.length<2)return 0;for(var t=0,r=0;r<n.length-1;r++){var e=n[r],u=n[r+1];t+=q(e[0],e[1],u[0],u[1])}return t}function Jn(n,t){if(t>1||t<0||n.length<2)return null;var r=Vn(n),e=r.segments,u=r.totalLength;if(0===u)return{x:n[0][0],y:n[0][1]};for(var o=0,a=null,i=0;i<e.length;i++){var c=e[i],f=c.from,h=c.to,l=c.length/u;if(t>=o&&t<=o+l){var s=(t-o)/l;a=qn.pointAt(f[0],f[1],h[0],h[1],s);break}o+=l}return a}function Kn(n,t){if(t>1||t<0||n.length<2)return 0;for(var r=Vn(n),e=r.segments,u=r.totalLength,o=0,a=0,i=0;i<e.length;i++){var c=e[i],f=c.from,h=c.to,l=c.length/u;if(t>=o&&t<=o+l){a=Math.atan2(h[1]-f[1],h[0]-f[0]);break}o+=l}return a}function Wn(n,t,r){for(var e=1/0,u=0;u<n.length-1;u++){var o=n[u],a=n[u+1],i=qn.pointDistance(o[0],o[1],a[0],a[1],t,r);i<e&&(e=i)}return e}var Zn={box:function(n){for(var t=[],r=[],e=0;e<n.length;e++){var u=n[e];t.push(u[0]),r.push(u[1])}return S(t,r)},length:function(n){return Hn(n)},pointAt:function(n,t){return Jn(n,t)},pointDistance:function(n,t,r){return Wn(n,t,r)},tangentAngle:function(n,t){return Kn(n,t)}};function $n(n){var t=n.slice(0);return n.length&&t.push(n[0]),t}var nt={box:function(n){return Zn.box(n)},length:function(n){return Hn($n(n))},pointAt:function(n,t){return Jn($n(n),t)},pointDistance:function(n,t,r){return Wn($n(n),t,r)},tangentAngle:function(n,t){return Kn($n(n),t)}}},9:function(n,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(n){"object"==typeof window&&(r=window)}n.exports=r}})}));
|
|
1
|
+
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Math=t():(n.G=n.G||{},n.G.Math=t())}(window,(function(){return function(n){var t={};function r(u){if(t[u])return t[u].exports;var e=t[u]={i:u,l:!1,exports:{}};return n[u].call(e.exports,e,e.exports,r),e.l=!0,e.exports}return r.m=n,r.c=t,r.d=function(n,t,u){r.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:u})},r.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},r.t=function(n,t){if(1&t&&(n=r(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var u=Object.create(null);if(r.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var e in n)r.d(u,e,function(t){return n[t]}.bind(null,e));return u},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.p="",r(r.s=8)}({8:function(n,t,r){"use strict";r.r(t),r.d(t,"Quad",(function(){return dn})),r.d(t,"Cubic",(function(){return xn})),r.d(t,"Arc",(function(){return jn})),r.d(t,"Line",(function(){return an})),r.d(t,"Polygon",(function(){return En})),r.d(t,"Polyline",(function(){return _n})),r.d(t,"Util",(function(){return u}));var u={};r.r(u),r.d(u,"distance",(function(){return i})),r.d(u,"isNumberEqual",(function(){return c})),r.d(u,"getBBoxByArray",(function(){return f})),r.d(u,"getBBoxRange",(function(){return h})),r.d(u,"piMod",(function(){return s}));var e={};r.r(e),r.d(e,"create",(function(){return v})),r.d(e,"clone",(function(){return M})),r.d(e,"fromValues",(function(){return p})),r.d(e,"copy",(function(){return y})),r.d(e,"set",(function(){return g})),r.d(e,"add",(function(){return x})),r.d(e,"subtract",(function(){return m})),r.d(e,"multiply",(function(){return b})),r.d(e,"divide",(function(){return A})),r.d(e,"ceil",(function(){return P})),r.d(e,"floor",(function(){return q})),r.d(e,"min",(function(){return I})),r.d(e,"max",(function(){return j})),r.d(e,"round",(function(){return w})),r.d(e,"scale",(function(){return D})),r.d(e,"scaleAndAdd",(function(){return O})),r.d(e,"distance",(function(){return L})),r.d(e,"squaredDistance",(function(){return S})),r.d(e,"length",(function(){return _})),r.d(e,"squaredLength",(function(){return B})),r.d(e,"negate",(function(){return E})),r.d(e,"inverse",(function(){return T})),r.d(e,"normalize",(function(){return z})),r.d(e,"dot",(function(){return F})),r.d(e,"cross",(function(){return G})),r.d(e,"lerp",(function(){return k})),r.d(e,"random",(function(){return X})),r.d(e,"transformMat2",(function(){return Y})),r.d(e,"transformMat2d",(function(){return C})),r.d(e,"transformMat3",(function(){return N})),r.d(e,"transformMat4",(function(){return Q})),r.d(e,"rotate",(function(){return R})),r.d(e,"angle",(function(){return U})),r.d(e,"zero",(function(){return V})),r.d(e,"str",(function(){return H})),r.d(e,"exactEquals",(function(){return J})),r.d(e,"equals",(function(){return K})),r.d(e,"len",(function(){return Z})),r.d(e,"sub",(function(){return $})),r.d(e,"mul",(function(){return nn})),r.d(e,"div",(function(){return tn})),r.d(e,"dist",(function(){return rn})),r.d(e,"sqrDist",(function(){return un})),r.d(e,"sqrLen",(function(){return en})),r.d(e,"forEach",(function(){return on}));Object.create;function o(n,t){var r="function"==typeof Symbol&&n[Symbol.iterator];if(!r)return n;var u,e,o=r.call(n),a=[];try{for(;(void 0===t||t-- >0)&&!(u=o.next()).done;)a.push(u.value)}catch(n){e={error:n}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return a}function a(n,t,r){if(r||2===arguments.length)for(var u,e=0,o=t.length;e<o;e++)!u&&e in t||(u||(u=Array.prototype.slice.call(t,0,e)),u[e]=t[e]);return n.concat(u||Array.prototype.slice.call(t))}Object.create;function i(n,t,r,u){var e=n-r,o=t-u;return Math.sqrt(e*e+o*o)}function c(n,t){return Math.abs(n-t)<.001}function f(n,t){var r=Math.min.apply(Math,a([],o(n),!1)),u=Math.min.apply(Math,a([],o(t),!1));return{x:r,y:u,width:Math.max.apply(Math,a([],o(n),!1))-r,height:Math.max.apply(Math,a([],o(t),!1))-u}}function h(n,t,r,u){return{minX:Math.min(n,r),maxX:Math.max(n,r),minY:Math.min(t,u),maxY:Math.max(t,u)}}function s(n){return(n+2*Math.PI)%(2*Math.PI)}var l="undefined"!=typeof Float32Array?Float32Array:Array,d=Math.random;Math.PI;function v(){var n=new l(2);return l!=Float32Array&&(n[0]=0,n[1]=0),n}function M(n){var t=new l(2);return t[0]=n[0],t[1]=n[1],t}function p(n,t){var r=new l(2);return r[0]=n,r[1]=t,r}function y(n,t){return n[0]=t[0],n[1]=t[1],n}function g(n,t,r){return n[0]=t,n[1]=r,n}function x(n,t,r){return n[0]=t[0]+r[0],n[1]=t[1]+r[1],n}function m(n,t,r){return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n}function b(n,t,r){return n[0]=t[0]*r[0],n[1]=t[1]*r[1],n}function A(n,t,r){return n[0]=t[0]/r[0],n[1]=t[1]/r[1],n}function P(n,t){return n[0]=Math.ceil(t[0]),n[1]=Math.ceil(t[1]),n}function q(n,t){return n[0]=Math.floor(t[0]),n[1]=Math.floor(t[1]),n}function I(n,t,r){return n[0]=Math.min(t[0],r[0]),n[1]=Math.min(t[1],r[1]),n}function j(n,t,r){return n[0]=Math.max(t[0],r[0]),n[1]=Math.max(t[1],r[1]),n}function w(n,t){return n[0]=Math.round(t[0]),n[1]=Math.round(t[1]),n}function D(n,t,r){return n[0]=t[0]*r,n[1]=t[1]*r,n}function O(n,t,r,u){return n[0]=t[0]+r[0]*u,n[1]=t[1]+r[1]*u,n}function L(n,t){var r=t[0]-n[0],u=t[1]-n[1];return Math.hypot(r,u)}function S(n,t){var r=t[0]-n[0],u=t[1]-n[1];return r*r+u*u}function _(n){var t=n[0],r=n[1];return Math.hypot(t,r)}function B(n){var t=n[0],r=n[1];return t*t+r*r}function E(n,t){return n[0]=-t[0],n[1]=-t[1],n}function T(n,t){return n[0]=1/t[0],n[1]=1/t[1],n}function z(n,t){var r=t[0],u=t[1],e=r*r+u*u;return e>0&&(e=1/Math.sqrt(e)),n[0]=t[0]*e,n[1]=t[1]*e,n}function F(n,t){return n[0]*t[0]+n[1]*t[1]}function G(n,t,r){var u=t[0]*r[1]-t[1]*r[0];return n[0]=n[1]=0,n[2]=u,n}function k(n,t,r,u){var e=t[0],o=t[1];return n[0]=e+u*(r[0]-e),n[1]=o+u*(r[1]-o),n}function X(n,t){t=t||1;var r=2*d()*Math.PI;return n[0]=Math.cos(r)*t,n[1]=Math.sin(r)*t,n}function Y(n,t,r){var u=t[0],e=t[1];return n[0]=r[0]*u+r[2]*e,n[1]=r[1]*u+r[3]*e,n}function C(n,t,r){var u=t[0],e=t[1];return n[0]=r[0]*u+r[2]*e+r[4],n[1]=r[1]*u+r[3]*e+r[5],n}function N(n,t,r){var u=t[0],e=t[1];return n[0]=r[0]*u+r[3]*e+r[6],n[1]=r[1]*u+r[4]*e+r[7],n}function Q(n,t,r){var u=t[0],e=t[1];return n[0]=r[0]*u+r[4]*e+r[12],n[1]=r[1]*u+r[5]*e+r[13],n}function R(n,t,r,u){var e=t[0]-r[0],o=t[1]-r[1],a=Math.sin(u),i=Math.cos(u);return n[0]=e*i-o*a+r[0],n[1]=e*a+o*i+r[1],n}function U(n,t){var r=n[0],u=n[1],e=t[0],o=t[1],a=Math.sqrt(r*r+u*u)*Math.sqrt(e*e+o*o),i=a&&(r*e+u*o)/a;return Math.acos(Math.min(Math.max(i,-1),1))}function V(n){return n[0]=0,n[1]=0,n}function H(n){return"vec2("+n[0]+", "+n[1]+")"}function J(n,t){return n[0]===t[0]&&n[1]===t[1]}function K(n,t){var r=n[0],u=n[1],e=t[0],o=t[1];return Math.abs(r-e)<=1e-6*Math.max(1,Math.abs(r),Math.abs(e))&&Math.abs(u-o)<=1e-6*Math.max(1,Math.abs(u),Math.abs(o))}Math.hypot||(Math.hypot=function(){for(var n=0,t=arguments.length;t--;)n+=arguments[t]*arguments[t];return Math.sqrt(n)});var W,Z=_,$=m,nn=b,tn=A,rn=L,un=S,en=B,on=(W=v(),function(n,t,r,u,e,o){var a,i;for(t||(t=2),r||(r=0),i=u?Math.min(u*t+r,n.length):n.length,a=r;a<i;a+=t)W[0]=n[a],W[1]=n[a+1],e(W,W,o),n[a]=W[0],n[a+1]=W[1];return n}),an={box:function(n,t,r,u){return f([n,r],[t,u])},length:function(n,t,r,u){return i(n,t,r,u)},pointAt:function(n,t,r,u,e){return{x:(1-e)*n+e*r,y:(1-e)*t+e*u}},pointDistance:function(n,t,r,u,e,o){var a=(r-n)*(e-n)+(u-t)*(o-t);return a<0?i(n,t,e,o):a>(r-n)*(r-n)+(u-t)*(u-t)?i(r,u,e,o):this.pointToLine(n,t,r,u,e,o)},pointToLine:function(n,t,r,u,o,a){var i=[r-n,u-t];if(e.exactEquals(i,[0,0]))return Math.sqrt((o-n)*(o-n)+(a-t)*(a-t));var c=[-i[1],i[0]];e.normalize(c,c);var f=[o-n,a-t];return Math.abs(e.dot(f,c))},tangentAngle:function(n,t,r,u){return Math.atan2(u-t,r-n)}};function cn(n,t,r,u,e,c){var f=-1,h=1/0,s=[r,u],l=20;c&&c>200&&(l=c/10);for(var d=1/l,v=d/10,M=0;M<=l;M++){var p=M*d,y=[e.apply(void 0,a([],o(n.concat([p])),!1)),e.apply(void 0,a([],o(t.concat([p])),!1))];(b=i(s[0],s[1],y[0],y[1]))<h&&(f=p,h=b)}if(0===f)return{x:n[0],y:t[0]};if(1===f){var g=n.length;return{x:n[g-1],y:t[g-1]}}h=1/0;for(M=0;M<32&&!(v<1e-4);M++){var x=f-v,m=f+v,b=(y=[e.apply(void 0,a([],o(n.concat([x])),!1)),e.apply(void 0,a([],o(t.concat([x])),!1))],i(s[0],s[1],y[0],y[1]));if(x>=0&&b<h)f=x,h=b;else{var A=[e.apply(void 0,a([],o(n.concat([m])),!1)),e.apply(void 0,a([],o(t.concat([m])),!1))],P=i(s[0],s[1],A[0],A[1]);m<=1&&P<h?(f=m,h=P):v*=.5}}return{x:e.apply(void 0,a([],o(n.concat([f])),!1)),y:e.apply(void 0,a([],o(t.concat([f])),!1))}}function fn(n,t,r,u){var e=1-u;return e*e*n+2*u*e*t+u*u*r}function hn(n,t,r){var u=n+r-2*t;if(c(u,0))return[.5];var e=(n-t)/u;return e<=1&&e>=0?[e]:[]}function sn(n,t,r,u){return 2*(1-u)*(t-n)+2*u*(r-t)}function ln(n,t,r,u,e,o,a){var i=fn(n,r,e,a),c=fn(t,u,o,a),f=an.pointAt(n,t,r,u,a),h=an.pointAt(r,u,e,o,a);return[[n,t,f.x,f.y,i,c],[i,c,h.x,h.y,e,o]]}var dn={box:function(n,t,r,u,e,o){var a=hn(n,r,e)[0],i=hn(t,u,o)[0],c=[n,e],h=[t,o];return void 0!==a&&c.push(fn(n,r,e,a)),void 0!==i&&h.push(fn(t,u,o,i)),f(c,h)},length:function(n,t,r,u,e,c){return function n(t,r,u,e,c,f,h){if(0===h)return(i(t,r,u,e)+i(u,e,c,f)+i(t,r,c,f))/2;var s=ln(t,r,u,e,c,f,.5),l=s[0],d=s[1];return l.push(h-1),d.push(h-1),n.apply(void 0,a([],o(l),!1))+n.apply(void 0,a([],o(d),!1))}(n,t,r,u,e,c,3)},nearestPoint:function(n,t,r,u,e,o,a,i){return cn([n,r,e],[t,u,o],a,i,fn)},pointDistance:function(n,t,r,u,e,o,a,c){var f=this.nearestPoint(n,t,r,u,e,o,a,c);return i(f.x,f.y,a,c)},interpolationAt:fn,pointAt:function(n,t,r,u,e,o,a){return{x:fn(n,r,e,a),y:fn(t,u,o,a)}},divide:function(n,t,r,u,e,o,a){return ln(n,t,r,u,e,o,a)},tangentAngle:function(n,t,r,u,e,o,a){var i=sn(n,r,e,a),c=sn(t,u,o,a);return s(Math.atan2(c,i))}};function vn(n,t,r,u,e){var o=1-e;return o*o*o*n+3*t*e*o*o+3*r*e*e*o+u*e*e*e}function Mn(n,t,r,u,e){var o=1-e;return 3*(o*o*(t-n)+2*o*e*(r-t)+e*e*(u-r))}function pn(n,t,r,u){var e,o,a,i=-3*n+9*t-9*r+3*u,f=6*n-12*t+6*r,h=3*t-3*n,s=[];if(c(i,0))c(f,0)||(e=-h/f)>=0&&e<=1&&s.push(e);else{var l=f*f-4*i*h;c(l,0)?s.push(-f/(2*i)):l>0&&(o=(-f-(a=Math.sqrt(l)))/(2*i),(e=(-f+a)/(2*i))>=0&&e<=1&&s.push(e),o>=0&&o<=1&&s.push(o))}return s}function yn(n,t,r,u,e,o,a,i,c){var f=vn(n,r,e,a,c),h=vn(t,u,o,i,c),s=an.pointAt(n,t,r,u,c),l=an.pointAt(r,u,e,o,c),d=an.pointAt(e,o,a,i,c),v=an.pointAt(s.x,s.y,l.x,l.y,c),M=an.pointAt(l.x,l.y,d.x,d.y,c);return[[n,t,s.x,s.y,v.x,v.y,f,h],[f,h,M.x,M.y,d.x,d.y,a,i]]}function gn(n,t,r,u,e,c,f,h,s){if(0===s)return function(n,t){for(var r=0,u=n.length,e=0;e<u;e++){r+=i(n[e],t[e],n[(e+1)%u],t[(e+1)%u])}return r/2}([n,r,e,f],[t,u,c,h]);var l=yn(n,t,r,u,e,c,f,h,.5),d=a(a([],o(l[0]),!1),[s-1],!1),v=a(a([],o(l[1]),!1),[s-1],!1);return gn.apply(void 0,a([],o(d),!1))+gn.apply(void 0,a([],o(v),!1))}var xn={extrema:pn,box:function(n,t,r,u,e,o,a,i){for(var c=[n,a],h=[t,i],s=pn(n,r,e,a),l=pn(t,u,o,i),d=0;d<s.length;d++)c.push(vn(n,r,e,a,s[d]));for(d=0;d<l.length;d++)h.push(vn(t,u,o,i,l[d]));return f(c,h)},length:function(n,t,r,u,e,o,a,i){return gn(n,t,r,u,e,o,a,i,3)},nearestPoint:function(n,t,r,u,e,o,a,i,c,f,h){return cn([n,r,e,a],[t,u,o,i],c,f,vn,h)},pointDistance:function(n,t,r,u,e,o,a,c,f,h,s){var l=this.nearestPoint(n,t,r,u,e,o,a,c,f,h,s);return i(l.x,l.y,f,h)},interpolationAt:vn,pointAt:function(n,t,r,u,e,o,a,i,c){return{x:vn(n,r,e,a,c),y:vn(t,u,o,i,c)}},divide:function(n,t,r,u,e,o,a,i,c){return yn(n,t,r,u,e,o,a,i,c)},tangentAngle:function(n,t,r,u,e,o,a,i,c){var f=Mn(n,r,e,a,c),h=Mn(t,u,o,i,c);return s(Math.atan2(h,f))}};function mn(n,t){var r=Math.abs(n);return t>0?r:-1*r}var bn=function(n,t,r,u,e,o){var a=r,i=u;if(0===a||0===i)return{x:n,y:t};for(var c=e-n,f=o-t,h=Math.abs(c),s=Math.abs(f),l=a*a,d=i*i,v=Math.PI/4,M=0,p=0,y=0;y<4;y++){M=a*Math.cos(v),p=i*Math.sin(v);var g=(l-d)*Math.pow(Math.cos(v),3)/a,x=(d-l)*Math.pow(Math.sin(v),3)/i,m=M-g,b=p-x,A=h-g,P=s-x,q=Math.hypot(b,m),I=Math.hypot(P,A);v+=q*Math.asin((m*P-b*A)/(q*I))/Math.sqrt(l+d-M*M-p*p),v=Math.min(Math.PI/2,Math.max(0,v))}return{x:n+mn(M,c),y:t+mn(p,f)}};function An(n,t,r,u,e,o){return r*Math.cos(e)*Math.cos(o)-u*Math.sin(e)*Math.sin(o)+n}function Pn(n,t,r,u,e,o){return r*Math.sin(e)*Math.cos(o)+u*Math.cos(e)*Math.sin(o)+t}function qn(n,t,r){return{x:n*Math.cos(r),y:t*Math.sin(r)}}function In(n,t,r){var u=Math.cos(r),e=Math.sin(r);return[n*u-t*e,n*e+t*u]}var jn={box:function(n,t,r,u,e,o,a){for(var i=function(n,t,r){return Math.atan(-t/n*Math.tan(r))}(r,u,e),c=1/0,f=-1/0,h=[o,a],s=2*-Math.PI;s<=2*Math.PI;s+=Math.PI){var l=i+s;o<a?o<l&&l<a&&h.push(l):a<l&&l<o&&h.push(l)}for(s=0;s<h.length;s++){var d=An(n,0,r,u,e,h[s]);d<c&&(c=d),d>f&&(f=d)}var v=function(n,t,r){return Math.atan(t/(n*Math.tan(r)))}(r,u,e),M=1/0,p=-1/0,y=[o,a];for(s=2*-Math.PI;s<=2*Math.PI;s+=Math.PI){var g=v+s;o<a?o<g&&g<a&&y.push(g):a<g&&g<o&&y.push(g)}for(s=0;s<y.length;s++){var x=Pn(0,t,r,u,e,y[s]);x<M&&(M=x),x>p&&(p=x)}return{x:c,y:M,width:f-c,height:p-M}},length:function(n,t,r,u,e,o,a){},nearestPoint:function(n,t,r,u,e,a,i,c,f){var h=o(In(c-n,f-t,-e),2),s=h[0],l=h[1],d=bn(0,0,r,u,s,l),v=function(n,t,r,u){return(Math.atan2(u*n,r*t)+2*Math.PI)%(2*Math.PI)}(r,u,d.x,d.y);v<a?d=qn(r,u,a):v>i&&(d=qn(r,u,i));var M=In(d.x,d.y,e);return{x:M[0]+n,y:M[1]+t}},pointDistance:function(n,t,r,u,e,o,a,c,f){var h=this.nearestPoint(n,t,r,u,e,o,a,c,f);return i(h.x,h.y,c,f)},pointAt:function(n,t,r,u,e,o,a,i){var c=(a-o)*i+o;return{x:An(n,0,r,u,e,c),y:Pn(0,t,r,u,e,c)}},tangentAngle:function(n,t,r,u,e,o,a,i){var c=(a-o)*i+o,f=function(n,t,r,u,e,o,a,i){return-1*r*Math.cos(e)*Math.sin(i)-u*Math.sin(e)*Math.cos(i)}(0,0,r,u,e,0,0,c),h=function(n,t,r,u,e,o,a,i){return-1*r*Math.sin(e)*Math.sin(i)+u*Math.cos(e)*Math.cos(i)}(0,0,r,u,e,0,0,c);return s(Math.atan2(h,f))}};function wn(n){for(var t=0,r=[],u=0;u<n.length-1;u++){var e=n[u],o=n[u+1],a=i(e[0],e[1],o[0],o[1]),c={from:e,to:o,length:a};r.push(c),t+=a}return{segments:r,totalLength:t}}function Dn(n){if(n.length<2)return 0;for(var t=0,r=0;r<n.length-1;r++){var u=n[r],e=n[r+1];t+=i(u[0],u[1],e[0],e[1])}return t}function On(n,t){if(t>1||t<0||n.length<2)return null;var r=wn(n),u=r.segments,e=r.totalLength;if(0===e)return{x:n[0][0],y:n[0][1]};for(var o=0,a=null,i=0;i<u.length;i++){var c=u[i],f=c.from,h=c.to,s=c.length/e;if(t>=o&&t<=o+s){var l=(t-o)/s;a=an.pointAt(f[0],f[1],h[0],h[1],l);break}o+=s}return a}function Ln(n,t){if(t>1||t<0||n.length<2)return 0;for(var r=wn(n),u=r.segments,e=r.totalLength,o=0,a=0,i=0;i<u.length;i++){var c=u[i],f=c.from,h=c.to,s=c.length/e;if(t>=o&&t<=o+s){a=Math.atan2(h[1]-f[1],h[0]-f[0]);break}o+=s}return a}function Sn(n,t,r){for(var u=1/0,e=0;e<n.length-1;e++){var o=n[e],a=n[e+1],i=an.pointDistance(o[0],o[1],a[0],a[1],t,r);i<u&&(u=i)}return u}var _n={box:function(n){for(var t=[],r=[],u=0;u<n.length;u++){var e=n[u];t.push(e[0]),r.push(e[1])}return f(t,r)},length:function(n){return Dn(n)},pointAt:function(n,t){return On(n,t)},pointDistance:function(n,t,r){return Sn(n,t,r)},tangentAngle:function(n,t){return Ln(n,t)}};function Bn(n){var t=n.slice(0);return n.length&&t.push(n[0]),t}var En={box:function(n){return _n.box(n)},length:function(n){return Dn(Bn(n))},pointAt:function(n,t){return On(Bn(n),t)},pointDistance:function(n,t,r){return Sn(Bn(n),t,r)},tangentAngle:function(n,t){return Ln(Bn(n),t)}}}})}));
|
package/es/util.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __read, __spreadArray } from "tslib";
|
|
2
2
|
/**
|
|
3
3
|
* 两点之间的距离
|
|
4
4
|
* @param {number} x1 起始点 x
|
|
@@ -17,10 +17,10 @@ export function isNumberEqual(v1, v2) {
|
|
|
17
17
|
return Math.abs(v1 - v2) < 0.001;
|
|
18
18
|
}
|
|
19
19
|
export function getBBoxByArray(xArr, yArr) {
|
|
20
|
-
var minX = min(xArr);
|
|
21
|
-
var minY = min(yArr);
|
|
22
|
-
var maxX = max(xArr);
|
|
23
|
-
var maxY = max(yArr);
|
|
20
|
+
var minX = Math.min.apply(Math, __spreadArray([], __read(xArr), false));
|
|
21
|
+
var minY = Math.min.apply(Math, __spreadArray([], __read(yArr), false));
|
|
22
|
+
var maxX = Math.max.apply(Math, __spreadArray([], __read(xArr), false));
|
|
23
|
+
var maxY = Math.max.apply(Math, __spreadArray([], __read(yArr), false));
|
|
24
24
|
return {
|
|
25
25
|
x: minX,
|
|
26
26
|
y: minY,
|
|
@@ -30,10 +30,10 @@ export function getBBoxByArray(xArr, yArr) {
|
|
|
30
30
|
}
|
|
31
31
|
export function getBBoxRange(x1, y1, x2, y2) {
|
|
32
32
|
return {
|
|
33
|
-
minX: min(
|
|
34
|
-
maxX: max(
|
|
35
|
-
minY: min(
|
|
36
|
-
maxY: max(
|
|
33
|
+
minX: Math.min(x1, x2),
|
|
34
|
+
maxX: Math.max(x1, x2),
|
|
35
|
+
minY: Math.min(y1, y2),
|
|
36
|
+
maxY: Math.max(y1, y2)
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
export function piMod(angle) {
|
package/lib/util.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.getBBoxRange = getBBoxRange;
|
|
|
9
9
|
exports.isNumberEqual = isNumberEqual;
|
|
10
10
|
exports.piMod = piMod;
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _tslib = require("tslib");
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* 两点之间的距离
|
|
@@ -30,10 +30,10 @@ function isNumberEqual(v1, v2) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function getBBoxByArray(xArr, yArr) {
|
|
33
|
-
var minX = (0,
|
|
34
|
-
var minY = (0,
|
|
35
|
-
var maxX = (0,
|
|
36
|
-
var maxY = (0,
|
|
33
|
+
var minX = Math.min.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(xArr), false));
|
|
34
|
+
var minY = Math.min.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(yArr), false));
|
|
35
|
+
var maxX = Math.max.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(xArr), false));
|
|
36
|
+
var maxY = Math.max.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(yArr), false));
|
|
37
37
|
return {
|
|
38
38
|
x: minX,
|
|
39
39
|
y: minY,
|
|
@@ -44,10 +44,10 @@ function getBBoxByArray(xArr, yArr) {
|
|
|
44
44
|
|
|
45
45
|
function getBBoxRange(x1, y1, x2, y2) {
|
|
46
46
|
return {
|
|
47
|
-
minX:
|
|
48
|
-
maxX:
|
|
49
|
-
minY:
|
|
50
|
-
maxY:
|
|
47
|
+
minX: Math.min(x1, x2),
|
|
48
|
+
maxX: Math.max(x1, x2),
|
|
49
|
+
minY: Math.min(y1, y2),
|
|
50
|
+
maxY: Math.max(y1, y2)
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g-math",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20-alpha.2",
|
|
4
4
|
"description": "Geometry util",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"gl-matrix": "^3.1.0",
|
|
36
|
-
"lodash-es": "^4.17.21",
|
|
37
36
|
"tslib": "^2.3.1"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
@@ -43,5 +42,5 @@
|
|
|
43
42
|
"umd": "webpack"
|
|
44
43
|
},
|
|
45
44
|
"homepage": "https://github.com/antvis/g#readme",
|
|
46
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "af1c0b90600f8b68d1008877bc98aefa308fefa8"
|
|
47
46
|
}
|