@antv/g-math 1.0.19-alpha.0 → 1.0.19
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 +1 -1
- package/lib/util.js +9 -9
- package/package.json +3 -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=8)}({8:function(n,t,r){"use strict";r.r(t),r.d(t,"Quad",(function(){return wn})),r.d(t,"Cubic",(function(){return En})),r.d(t,"Arc",(function(){return Nn})),r.d(t,"Line",(function(){return mn})),r.d(t,"Polygon",(function(){return Un})),r.d(t,"Polyline",(function(){return Qn})),r.d(t,"Util",(function(){return e}));var e={};r.r(e),r.d(e,"distance",(function(){return m})),r.d(e,"isNumberEqual",(function(){return b})),r.d(e,"getBBoxByArray",(function(){return A})),r.d(e,"getBBoxRange",(function(){return P})),r.d(e,"piMod",(function(){return j}));var u={};r.r(u),r.d(u,"create",(function(){return I})),r.d(u,"clone",(function(){return q})),r.d(u,"fromValues",(function(){return S})),r.d(u,"copy",(function(){return D})),r.d(u,"set",(function(){return L})),r.d(u,"add",(function(){return E})),r.d(u,"subtract",(function(){return T})),r.d(u,"multiply",(function(){return _})),r.d(u,"divide",(function(){return k})),r.d(u,"ceil",(function(){return z})),r.d(u,"floor",(function(){return B})),r.d(u,"min",(function(){return F})),r.d(u,"max",(function(){return N})),r.d(u,"round",(function(){return G})),r.d(u,"scale",(function(){return C})),r.d(u,"scaleAndAdd",(function(){return V})),r.d(u,"distance",(function(){return X})),r.d(u,"squaredDistance",(function(){return Y})),r.d(u,"length",(function(){return Q})),r.d(u,"squaredLength",(function(){return R})),r.d(u,"negate",(function(){return U})),r.d(u,"inverse",(function(){return W})),r.d(u,"normalize",(function(){return H})),r.d(u,"dot",(function(){return J})),r.d(u,"cross",(function(){return K})),r.d(u,"lerp",(function(){return Z})),r.d(u,"random",(function(){return $})),r.d(u,"transformMat2",(function(){return nn})),r.d(u,"transformMat2d",(function(){return tn})),r.d(u,"transformMat3",(function(){return rn})),r.d(u,"transformMat4",(function(){return en})),r.d(u,"rotate",(function(){return un})),r.d(u,"angle",(function(){return on})),r.d(u,"zero",(function(){return an})),r.d(u,"str",(function(){return cn})),r.d(u,"exactEquals",(function(){return fn})),r.d(u,"equals",(function(){return hn})),r.d(u,"len",(function(){return pn})),r.d(u,"sub",(function(){return ln})),r.d(u,"mul",(function(){return vn})),r.d(u,"div",(function(){return dn})),r.d(u,"dist",(function(){return yn})),r.d(u,"sqrDist",(function(){return Mn})),r.d(u,"sqrLen",(function(){return gn})),r.d(u,"forEach",(function(){return xn}));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={}.toString,c=function(n,t){return i.call(n)==="[object "+t+"]"},f=function(n){return c(n,"Function")},h=function(n){return Array.isArray?Array.isArray(n):c(n,"Array")},s=function(n){var t=typeof n;return null!==n&&"object"===t||"function"===t};var p=function(n,t){if(n)if(h(n))for(var r=0,e=n.length;r<e&&!1!==t(n[r],r);r++);else if(s(n))for(var u in n)if(n.hasOwnProperty(u)&&!1===t(n[u],u))break};Object.keys;var l=function(n){if(h(n))return n.reduce((function(n,t){return Math.max(n,t)}),n[0])},v=function(n){if(h(n))return n.reduce((function(n,t){return Math.min(n,t)}),n[0])},d=Array.prototype,y=(d.splice,d.indexOf,Array.prototype.splice,function(n){return c(n,"String")});Object.prototype.hasOwnProperty;var M=function(n){return c(n,"Number")};Number.isInteger&&Number.isInteger;Math.PI,parseInt,Math.PI;var g=Object.values?function(n){return Object.values(n)}:function(n){var t=[];return p(n,(function(r,e){f(n)&&"prototype"===e||t.push(r)})),t};Object.prototype;Object.prototype.hasOwnProperty;var x;Object.prototype.hasOwnProperty;(function(n,t){if(!f(n))throw new TypeError("Expected a function");var r=function(){for(var e=[],u=0;u<arguments.length;u++)e[u]=arguments[u];var o=t?t.apply(this,e):e[0],a=r.cache;if(a.has(o))return a.get(o);var i=n.apply(this,e);return a.set(o,i),i};r.cache=new Map})((function(n,t){void 0===t&&(t={});var r=t.fontSize,e=t.fontFamily,u=t.fontWeight,o=t.fontStyle,a=t.fontVariant;return x||(x=document.createElement("canvas").getContext("2d")),x.font=[o,a,u,r+"px",e].join(" "),x.measureText(y(n)?n:"").width}),(function(n,t){return void 0===t&&(t={}),function(){for(var n=0,t=0,r=arguments.length;t<r;t++)n+=arguments[t].length;var e=Array(n),u=0;for(t=0;t<r;t++)for(var o=arguments[t],a=0,i=o.length;a<i;a++,u++)e[u]=o[a];return e}([n],g(t)).join("")})),function(){function n(){this.map={}}n.prototype.has=function(n){return void 0!==this.map[n]},n.prototype.get=function(n,t){var r=this.map[n];return void 0===r?t:r},n.prototype.set=function(n,t){this.map[n]=t},n.prototype.clear=function(){this.map={}},n.prototype.delete=function(n){delete this.map[n]},n.prototype.size=function(){return Object.keys(this.map).length}}();function m(n,t,r,e){var u=n-r,o=t-e;return Math.sqrt(u*u+o*o)}function b(n,t){return Math.abs(n-t)<.001}function A(n,t){var r=v(n),e=v(t);return{x:r,y:e,width:l(n)-r,height:l(t)-e}}function P(n,t,r,e){return{minX:v([n,r]),maxX:l([n,r]),minY:v([t,e]),maxY:l([t,e])}}function j(n){return(n+2*Math.PI)%(2*Math.PI)}var O="undefined"!=typeof Float32Array?Float32Array:Array,w=Math.random;Math.PI;function I(){var n=new O(2);return O!=Float32Array&&(n[0]=0,n[1]=0),n}function q(n){var t=new O(2);return t[0]=n[0],t[1]=n[1],t}function S(n,t){var r=new O(2);return r[0]=n,r[1]=t,r}function D(n,t){return n[0]=t[0],n[1]=t[1],n}function L(n,t,r){return n[0]=t,n[1]=r,n}function E(n,t,r){return n[0]=t[0]+r[0],n[1]=t[1]+r[1],n}function T(n,t,r){return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n}function _(n,t,r){return n[0]=t[0]*r[0],n[1]=t[1]*r[1],n}function k(n,t,r){return n[0]=t[0]/r[0],n[1]=t[1]/r[1],n}function z(n,t){return n[0]=Math.ceil(t[0]),n[1]=Math.ceil(t[1]),n}function B(n,t){return n[0]=Math.floor(t[0]),n[1]=Math.floor(t[1]),n}function F(n,t,r){return n[0]=Math.min(t[0],r[0]),n[1]=Math.min(t[1],r[1]),n}function N(n,t,r){return n[0]=Math.max(t[0],r[0]),n[1]=Math.max(t[1],r[1]),n}function G(n,t){return n[0]=Math.round(t[0]),n[1]=Math.round(t[1]),n}function C(n,t,r){return n[0]=t[0]*r,n[1]=t[1]*r,n}function V(n,t,r,e){return n[0]=t[0]+r[0]*e,n[1]=t[1]+r[1]*e,n}function X(n,t){var r=t[0]-n[0],e=t[1]-n[1];return Math.hypot(r,e)}function Y(n,t){var r=t[0]-n[0],e=t[1]-n[1];return r*r+e*e}function Q(n){var t=n[0],r=n[1];return Math.hypot(t,r)}function R(n){var t=n[0],r=n[1];return t*t+r*r}function U(n,t){return n[0]=-t[0],n[1]=-t[1],n}function W(n,t){return n[0]=1/t[0],n[1]=1/t[1],n}function H(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 J(n,t){return n[0]*t[0]+n[1]*t[1]}function K(n,t,r){var e=t[0]*r[1]-t[1]*r[0];return n[0]=n[1]=0,n[2]=e,n}function Z(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 $(n,t){t=t||1;var r=2*w()*Math.PI;return n[0]=Math.cos(r)*t,n[1]=Math.sin(r)*t,n}function nn(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 tn(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 rn(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 en(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 un(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 on(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 an(n){return n[0]=0,n[1]=0,n}function cn(n){return"vec2("+n[0]+", "+n[1]+")"}function fn(n,t){return n[0]===t[0]&&n[1]===t[1]}function hn(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 sn,pn=Q,ln=T,vn=_,dn=k,yn=X,Mn=Y,gn=R,xn=(sn=I(),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)sn[0]=n[a],sn[1]=n[a+1],u(sn,sn,o),n[a]=sn[0],n[a+1]=sn[1];return n}),mn={box:function(n,t,r,e){return A([n,r],[t,e])},length:function(n,t,r,e){return m(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?m(n,t,u,o):a>(r-n)*(r-n)+(e-t)*(e-t)?m(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 bn(n,t,r,e,u,i){var c=-1,f=1/0,h=[r,e],s=20;i&&i>200&&(s=i/10);for(var p=1/s,l=p/10,v=0;v<=s;v++){var d=v*p,y=[u.apply(void 0,a([],o(n.concat([d])),!1)),u.apply(void 0,a([],o(t.concat([d])),!1))];(b=m(h[0],h[1],y[0],y[1]))<f&&(c=d,f=b)}if(0===c)return{x:n[0],y:t[0]};if(1===c){var M=n.length;return{x:n[M-1],y:t[M-1]}}f=1/0;for(v=0;v<32&&!(l<1e-4);v++){var g=c-l,x=c+l,b=(y=[u.apply(void 0,a([],o(n.concat([g])),!1)),u.apply(void 0,a([],o(t.concat([g])),!1))],m(h[0],h[1],y[0],y[1]));if(g>=0&&b<f)c=g,f=b;else{var A=[u.apply(void 0,a([],o(n.concat([x])),!1)),u.apply(void 0,a([],o(t.concat([x])),!1))],P=m(h[0],h[1],A[0],A[1]);x<=1&&P<f?(c=x,f=P):l*=.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 An(n,t,r,e){var u=1-e;return u*u*n+2*e*u*t+e*e*r}function Pn(n,t,r){var e=n+r-2*t;if(b(e,0))return[.5];var u=(n-t)/e;return u<=1&&u>=0?[u]:[]}function jn(n,t,r,e){return 2*(1-e)*(t-n)+2*e*(r-t)}function On(n,t,r,e,u,o,a){var i=An(n,r,u,a),c=An(t,e,o,a),f=mn.pointAt(n,t,r,e,a),h=mn.pointAt(r,e,u,o,a);return[[n,t,f.x,f.y,i,c],[i,c,h.x,h.y,u,o]]}var wn={box:function(n,t,r,e,u,o){var a=Pn(n,r,u)[0],i=Pn(t,e,o)[0],c=[n,u],f=[t,o];return void 0!==a&&c.push(An(n,r,u,a)),void 0!==i&&f.push(An(t,e,o,i)),A(c,f)},length:function(n,t,r,e,u,i){return function n(t,r,e,u,i,c,f){if(0===f)return(m(t,r,e,u)+m(e,u,i,c)+m(t,r,i,c))/2;var h=On(t,r,e,u,i,c,.5),s=h[0],p=h[1];return s.push(f-1),p.push(f-1),n.apply(void 0,a([],o(s),!1))+n.apply(void 0,a([],o(p),!1))}(n,t,r,e,u,i,3)},nearestPoint:function(n,t,r,e,u,o,a,i){return bn([n,r,u],[t,e,o],a,i,An)},pointDistance:function(n,t,r,e,u,o,a,i){var c=this.nearestPoint(n,t,r,e,u,o,a,i);return m(c.x,c.y,a,i)},interpolationAt:An,pointAt:function(n,t,r,e,u,o,a){return{x:An(n,r,u,a),y:An(t,e,o,a)}},divide:function(n,t,r,e,u,o,a){return On(n,t,r,e,u,o,a)},tangentAngle:function(n,t,r,e,u,o,a){var i=jn(n,r,u,a),c=jn(t,e,o,a);return j(Math.atan2(c,i))}};function In(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 qn(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 Sn(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(b(i,0))b(c,0)||(u=-f/c)>=0&&u<=1&&h.push(u);else{var s=c*c-4*i*f;b(s,0)?h.push(-c/(2*i)):s>0&&(o=(-c-(a=Math.sqrt(s)))/(2*i),(u=(-c+a)/(2*i))>=0&&u<=1&&h.push(u),o>=0&&o<=1&&h.push(o))}return h}function Dn(n,t,r,e,u,o,a,i,c){var f=In(n,r,u,a,c),h=In(t,e,o,i,c),s=mn.pointAt(n,t,r,e,c),p=mn.pointAt(r,e,u,o,c),l=mn.pointAt(u,o,a,i,c),v=mn.pointAt(s.x,s.y,p.x,p.y,c),d=mn.pointAt(p.x,p.y,l.x,l.y,c);return[[n,t,s.x,s.y,v.x,v.y,f,h],[f,h,d.x,d.y,l.x,l.y,a,i]]}function Ln(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+=m(n[u],t[u],n[(u+1)%e],t[(u+1)%e])}return r/2}([n,r,u,c],[t,e,i,f]);var s=Dn(n,t,r,e,u,i,c,f,.5),p=a(a([],o(s[0]),!1),[h-1],!1),l=a(a([],o(s[1]),!1),[h-1],!1);return Ln.apply(void 0,a([],o(p),!1))+Ln.apply(void 0,a([],o(l),!1))}var En={extrema:Sn,box:function(n,t,r,e,u,o,a,i){for(var c=[n,a],f=[t,i],h=Sn(n,r,u,a),s=Sn(t,e,o,i),p=0;p<h.length;p++)c.push(In(n,r,u,a,h[p]));for(p=0;p<s.length;p++)f.push(In(t,e,o,i,s[p]));return A(c,f)},length:function(n,t,r,e,u,o,a,i){return Ln(n,t,r,e,u,o,a,i,3)},nearestPoint:function(n,t,r,e,u,o,a,i,c,f,h){return bn([n,r,u,a],[t,e,o,i],c,f,In,h)},pointDistance:function(n,t,r,e,u,o,a,i,c,f,h){var s=this.nearestPoint(n,t,r,e,u,o,a,i,c,f,h);return m(s.x,s.y,c,f)},interpolationAt:In,pointAt:function(n,t,r,e,u,o,a,i,c){return{x:In(n,r,u,a,c),y:In(t,e,o,i,c)}},divide:function(n,t,r,e,u,o,a,i,c){return Dn(n,t,r,e,u,o,a,i,c)},tangentAngle:function(n,t,r,e,u,o,a,i,c){var f=qn(n,r,u,a,c),h=qn(t,e,o,i,c);return j(Math.atan2(h,f))}};function Tn(n,t){var r=Math.abs(n);return t>0?r:-1*r}var _n=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),s=Math.abs(f),p=a*a,l=i*i,v=Math.PI/4,d=0,y=0,M=0;M<4;M++){d=a*Math.cos(v),y=i*Math.sin(v);var g=(p-l)*Math.pow(Math.cos(v),3)/a,x=(l-p)*Math.pow(Math.sin(v),3)/i,m=d-g,b=y-x,A=h-g,P=s-x,j=Math.hypot(b,m),O=Math.hypot(P,A);v+=j*Math.asin((m*P-b*A)/(j*O))/Math.sqrt(p+l-d*d-y*y),v=Math.min(Math.PI/2,Math.max(0,v))}return{x:n+Tn(d,c),y:t+Tn(y,f)}};function kn(n,t,r,e,u,o){return r*Math.cos(u)*Math.cos(o)-e*Math.sin(u)*Math.sin(o)+n}function zn(n,t,r,e,u,o){return r*Math.sin(u)*Math.cos(o)+e*Math.cos(u)*Math.sin(o)+t}function Bn(n,t,r){return{x:n*Math.cos(r),y:t*Math.sin(r)}}function Fn(n,t,r){var e=Math.cos(r),u=Math.sin(r);return[n*e-t*u,n*u+t*e]}var Nn={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],s=2*-Math.PI;s<=2*Math.PI;s+=Math.PI){var p=i+s;o<a?o<p&&p<a&&h.push(p):a<p&&p<o&&h.push(p)}for(s=0;s<h.length;s++){var l=kn(n,0,r,e,u,h[s]);l<c&&(c=l),l>f&&(f=l)}var v=function(n,t,r){return Math.atan(t/(n*Math.tan(r)))}(r,e,u),d=1/0,y=-1/0,M=[o,a];for(s=2*-Math.PI;s<=2*Math.PI;s+=Math.PI){var g=v+s;o<a?o<g&&g<a&&M.push(g):a<g&&g<o&&M.push(g)}for(s=0;s<M.length;s++){var x=zn(0,t,r,e,u,M[s]);x<d&&(d=x),x>y&&(y=x)}return{x:c,y:d,width:f-c,height:y-d}},length:function(n,t,r,e,u,o,a){},nearestPoint:function(n,t,r,e,u,a,i,c,f){var h=o(Fn(c-n,f-t,-u),2),s=h[0],p=h[1],l=_n(0,0,r,e,s,p),v=function(n,t,r,e){return(Math.atan2(e*n,r*t)+2*Math.PI)%(2*Math.PI)}(r,e,l.x,l.y);v<a?l=Bn(r,e,a):v>i&&(l=Bn(r,e,i));var d=Fn(l.x,l.y,u);return{x:d[0]+n,y:d[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 m(f.x,f.y,i,c)},pointAt:function(n,t,r,e,u,o,a,i){var c=(a-o)*i+o;return{x:kn(n,0,r,e,u,c),y:zn(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 j(Math.atan2(h,f))}};function Gn(n){for(var t=0,r=[],e=0;e<n.length-1;e++){var u=n[e],o=n[e+1],a=m(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 Cn(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+=m(e[0],e[1],u[0],u[1])}return t}function Vn(n,t){if(t>1||t<0||n.length<2)return null;var r=Gn(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,s=c.length/u;if(t>=o&&t<=o+s){var p=(t-o)/s;a=mn.pointAt(f[0],f[1],h[0],h[1],p);break}o+=s}return a}function Xn(n,t){if(t>1||t<0||n.length<2)return 0;for(var r=Gn(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,s=c.length/u;if(t>=o&&t<=o+s){a=Math.atan2(h[1]-f[1],h[0]-f[0]);break}o+=s}return a}function Yn(n,t,r){for(var e=1/0,u=0;u<n.length-1;u++){var o=n[u],a=n[u+1],i=mn.pointDistance(o[0],o[1],a[0],a[1],t,r);i<e&&(e=i)}return e}var Qn={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 A(t,r)},length:function(n){return Cn(n)},pointAt:function(n,t){return Vn(n,t)},pointDistance:function(n,t,r){return Yn(n,t,r)},tangentAngle:function(n,t){return Xn(n,t)}};function Rn(n){var t=n.slice(0);return n.length&&t.push(n[0]),t}var Un={box:function(n){return Qn.box(n)},length:function(n){return Cn(Rn(n))},pointAt:function(n,t){return Vn(Rn(n),t)},pointDistance:function(n,t,r){return Yn(Rn(n),t,r)},tangentAngle:function(n,t){return Xn(Rn(n),t)}}}})}));
|
|
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}})}));
|
package/es/util.js
CHANGED
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 _lodashEs = require("lodash-es");
|
|
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 = (0, _lodashEs.min)(xArr);
|
|
34
|
+
var minY = (0, _lodashEs.min)(yArr);
|
|
35
|
+
var maxX = (0, _lodashEs.max)(xArr);
|
|
36
|
+
var maxY = (0, _lodashEs.max)(yArr);
|
|
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: (0,
|
|
48
|
-
maxX: (0,
|
|
49
|
-
minY: (0,
|
|
50
|
-
maxY: (0,
|
|
47
|
+
minX: (0, _lodashEs.min)([x1, x2]),
|
|
48
|
+
maxX: (0, _lodashEs.max)([x1, x2]),
|
|
49
|
+
minY: (0, _lodashEs.min)([y1, y2]),
|
|
50
|
+
maxY: (0, _lodashEs.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.19
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "Geometry util",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"url": "https://github.com/antvis/g/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@antv/util": "^2.0.13",
|
|
36
35
|
"gl-matrix": "^3.1.0",
|
|
36
|
+
"lodash-es": "^4.17.21",
|
|
37
37
|
"tslib": "^2.3.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"umd": "webpack"
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://github.com/antvis/g#readme",
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "a52a7c8d754925e5732baf3faea156332748365f"
|
|
47
47
|
}
|