@antv/g-math 1.0.1 → 1.0.5
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/LICENSE +21 -0
- package/dist/index.umd.js +1 -0
- package/package.json +10 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 AntV team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +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 sn})),r.d(u,"sub",(function(){return pn})),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}));var o={}.toString,a=function(n,t){return o.call(n)==="[object "+t+"]"},i=function(n){return a(n,"Function")},c=function(n){return Array.isArray?Array.isArray(n):a(n,"Array")},f=function(n){var t=typeof n;return null!==n&&"object"===t||"function"===t};var h=function(n,t){if(n)if(c(n))for(var r=0,e=n.length;r<e&&!1!==t(n[r],r);r++);else if(f(n))for(var u in n)if(n.hasOwnProperty(u)&&!1===t(n[u],u))break};Object.keys;var l=function(n){if(c(n))return n.reduce((function(n,t){return Math.max(n,t)}),n[0])},s=function(n){if(c(n))return n.reduce((function(n,t){return Math.min(n,t)}),n[0])},p=Array.prototype,v=(p.splice,p.indexOf,Array.prototype.splice,function(n){return a(n,"String")});Object.prototype.hasOwnProperty;var d=function(n){return a(n,"Number")};Number.isInteger&&Number.isInteger;Math.PI,parseInt,Math.PI;var y=Object.values?function(n){return Object.values(n)}:function(n){var t=[];return h(n,(function(r,e){i(n)&&"prototype"===e||t.push(r)})),t};Object.prototype;Object.prototype.hasOwnProperty;Object.prototype.hasOwnProperty;Object.create;function M(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 g(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))}var x;Object.create;(function(n,t){if(!i(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(v(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],y(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=s(n),e=s(t);return{x:r,y:e,width:l(n)-r,height:l(t)-e}}function P(n,t,r,e){return{minX:s([n,r]),maxX:l([n,r]),minY:s([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 ln,sn=Q,pn=T,vn=_,dn=k,yn=X,Mn=Y,gn=R,xn=(ln=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)ln[0]=n[a],ln[1]=n[a+1],u(ln,ln,o),n[a]=ln[0],n[a+1]=ln[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,o){var a=-1,i=1/0,c=[r,e],f=20;o&&o>200&&(f=o/10);for(var h=1/f,l=h/10,s=0;s<=f;s++){var p=s*h,v=[u.apply(null,n.concat([p])),u.apply(null,t.concat([p]))];(g=m(c[0],c[1],v[0],v[1]))<i&&(a=p,i=g)}if(0===a)return{x:n[0],y:t[0]};if(1===a){var d=n.length;return{x:n[d-1],y:t[d-1]}}i=1/0;for(s=0;s<32&&!(l<1e-4);s++){var y=a-l,M=a+l,g=(v=[u.apply(null,n.concat([y])),u.apply(null,t.concat([y]))],m(c[0],c[1],v[0],v[1]));if(y>=0&&g<i)a=y,i=g;else{var x=[u.apply(null,n.concat([M])),u.apply(null,t.concat([M]))],b=m(c[0],c[1],x[0],x[1]);M<=1&&b<i?(a=M,i=b):l*=.5}}return{x:u.apply(null,n.concat([a])),y:u.apply(null,t.concat([a]))}}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,o){return function n(t,r,e,u,o,a,i){if(0===i)return(m(t,r,e,u)+m(e,u,o,a)+m(t,r,o,a))/2;var c=On(t,r,e,u,o,a,.5),f=c[0],h=c[1];return f.push(i-1),h.push(i-1),n.apply(null,f)+n.apply(null,h)}(n,t,r,e,u,o,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 l=c*c-4*i*f;b(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 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),l=mn.pointAt(n,t,r,e,c),s=mn.pointAt(r,e,u,o,c),p=mn.pointAt(u,o,a,i,c),v=mn.pointAt(l.x,l.y,s.x,s.y,c),d=mn.pointAt(s.x,s.y,p.x,p.y,c);return[[n,t,l.x,l.y,v.x,v.y,f,h],[f,h,d.x,d.y,p.x,p.y,a,i]]}function Ln(n,t,r,e,u,o,a,i,c){if(0===c)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,a],[t,e,o,i]);var f=Dn(n,t,r,e,u,o,a,i,.5),h=g(g([],M(f[0]),!1),[c-1],!1),l=g(g([],M(f[1]),!1),[c-1],!1);return Ln.apply(null,h)+Ln.apply(null,l)}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),l=Sn(t,e,o,i),s=0;s<h.length;s++)c.push(In(n,r,u,a,h[s]));for(s=0;s<l.length;s++)f.push(In(t,e,o,i,l[s]));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 l=this.nearestPoint(n,t,r,e,u,o,a,i,c,f,h);return m(l.x,l.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),l=Math.abs(f),s=a*a,p=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=(s-p)*Math.pow(Math.cos(v),3)/a,x=(p-s)*Math.pow(Math.sin(v),3)/i,m=d-g,b=y-x,A=h-g,P=l-x,j=Math.hypot(b,m),O=Math.hypot(P,A);v+=j*Math.asin((m*P-b*A)/(j*O))/Math.sqrt(s+p-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],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 p=kn(n,0,r,e,u,h[l]);p<c&&(c=p),p>f&&(f=p)}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(l=2*-Math.PI;l<=2*Math.PI;l+=Math.PI){var g=v+l;o<a?o<g&&g<a&&M.push(g):a<g&&g<o&&M.push(g)}for(l=0;l<M.length;l++){var x=zn(0,t,r,e,u,M[l]);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,o,a,i,c){var f=M(Fn(i-n,c-t,-u),2),h=f[0],l=f[1],s=_n(0,0,r,e,h,l),p=function(n,t,r,e){return(Math.atan2(e*n,r*t)+2*Math.PI)%(2*Math.PI)}(r,e,s.x,s.y);p<o?s=Bn(r,e,o):p>a&&(s=Bn(r,e,a));var v=Fn(s.x,s.y,u);return{x:v[0]+n,y:v[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,l=c.length/u;if(t>=o&&t<=o+l){var s=(t-o)/l;a=mn.pointAt(f[0],f[1],h[0],h[1],s);break}o+=l}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,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 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)}}}})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g-math",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Geometry util",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -31,9 +31,17 @@
|
|
|
31
31
|
"bugs": {
|
|
32
32
|
"url": "https://github.com/antvis/g/issues"
|
|
33
33
|
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@antv/util": "^2.0.13",
|
|
36
|
+
"gl-matrix": "^3.1.0",
|
|
37
|
+
"tslib": "^2.3.1"
|
|
38
|
+
},
|
|
34
39
|
"devDependencies": {
|
|
35
40
|
"@types/jest": "^25.0.0"
|
|
36
41
|
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"umd": "webpack"
|
|
44
|
+
},
|
|
37
45
|
"homepage": "https://github.com/antvis/g#readme",
|
|
38
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "039cea4e9baf6988a7d6105bb3a907ed816a2fd9"
|
|
39
47
|
}
|