Socket
Socket
Sign inDemoInstall

@antv/g-math

Package Overview
Dependencies
Maintainers
64
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-math - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3-next.0

2

dist/index.umd.min.js

@@ -1,2 +0,2 @@

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((n="undefined"!=typeof globalThis?globalThis:n||self).G=n.G||{},n.G.Math={}))}(this,(function(n){"use strict";function t(n,t){var r="function"==typeof Symbol&&n[Symbol.iterator];if(!r)return n;var a,o,e=r.call(n),u=[];try{for(;(void 0===t||t-- >0)&&!(a=e.next()).done;)u.push(a.value)}catch(n){o={error:n}}finally{try{a&&!a.done&&(r=e.return)&&r.call(e)}finally{if(o)throw o.error}}return u}function r(n,t,r){if(r||2===arguments.length)for(var a,o=0,e=t.length;e>o;o++)!a&&o in t||(a||(a=Array.prototype.slice.call(t,0,o)),a[o]=t[o]);return n.concat(a||Array.prototype.slice.call(t))}function a(n,t,r,a){var o=n-r,e=t-a;return Math.sqrt(o*o+e*e)}function o(n,a){var o=Math.min.apply(Math,r([],t(n),!1)),e=Math.min.apply(Math,r([],t(a),!1));return{x:o,y:e,width:Math.max.apply(Math,r([],t(n),!1))-o,height:Math.max.apply(Math,r([],t(a),!1))-e}}function e(n){return(n+2*Math.PI)%(2*Math.PI)}function u(n,t){var r=Math.abs(n);return t>0?r:-1*r}function i(n,t,r,a,o,e){return r*Math.cos(o)*Math.cos(e)-a*Math.sin(o)*Math.sin(e)+n}function h(n,t,r,a,o,e){return r*Math.sin(o)*Math.cos(e)+a*Math.cos(o)*Math.sin(e)+t}function c(n,t,r){return{x:n*Math.cos(r),y:t*Math.sin(r)}}function f(n,t,r){var a=Math.cos(r),o=Math.sin(r);return[n*a-t*o,n*o+t*a]}var l,s="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var n=0,t=arguments.length;t--;)n+=arguments[t]*arguments[t];return Math.sqrt(n)}),l=new s(2),s!=Float32Array&&(l[0]=0,l[1]=0);var v=1e-5;function p(n,t,r){return void 0===r&&(r=v),r>Math.abs(n-t)}var y=1e-4;function M(n,o,e,u,i,h){var c=-1,f=1/0,l=[e,u],s=20;h&&h>200&&(s=h/10);for(var v=1/s,p=v/10,M=0;s>=M;M++){var g=M*v,x=[i.apply(void 0,r([],t(n.concat([g])),!1)),i.apply(void 0,r([],t(o.concat([g])),!1))];f>(m=a(l[0],l[1],x[0],x[1]))&&(c=g,f=m)}if(0===c)return{x:n[0],y:o[0]};if(1===c){var d=n.length;return{x:n[d-1],y:o[d-1]}}f=1/0;for(M=0;32>M&&y<=p;M++){var P=c-p,b=c+p,m=(x=[i.apply(void 0,r([],t(n.concat([P])),!1)),i.apply(void 0,r([],t(o.concat([P])),!1))],a(l[0],l[1],x[0],x[1]));if(P>=0&&f>m)c=P,f=m;else{var A=[i.apply(void 0,r([],t(n.concat([b])),!1)),i.apply(void 0,r([],t(o.concat([b])),!1))],I=a(l[0],l[1],A[0],A[1]);1>=b&&f>I?(c=b,f=I):p*=.5}}return{x:i.apply(void 0,r([],t(n.concat([c])),!1)),y:i.apply(void 0,r([],t(o.concat([c])),!1))}}function g(n,t,r,a,o){return{x:(1-o)*n+o*r,y:(1-o)*t+o*a}}function x(n,t,r,o,e,u){var i=(r-n)*(e-n)+(o-t)*(u-t);return 0>i?a(n,t,e,u):i>(r-n)*(r-n)+(o-t)*(o-t)?a(r,o,e,u):d(n,t,r,o,e,u)}function d(n,t,r,a,o,e){var u=[r-n,a-t];if(function(n,t){return n[0]===t[0]&&n[1]===t[1]}(u,[0,0]))return Math.sqrt((o-n)*(o-n)+(e-t)*(e-t));var i=[-u[1],u[0]];return function(n,t){var r=t[0],a=t[1],o=r*r+a*a;o>0&&(o=1/Math.sqrt(o)),n[0]=t[0]*o,n[1]=t[1]*o}(i,i),Math.abs(function(n,t){return n[0]*t[0]+n[1]*t[1]}([o-n,e-t],i))}function P(n,t,r,a,o){var e=1-o;return e*e*e*n+3*t*o*e*e+3*r*o*o*e+a*o*o*o}function b(n,t,r,a,o){var e=1-o;return 3*(e*e*(t-n)+2*e*o*(r-t)+o*o*(a-r))}function m(n,t,r,a){var o,e,u,i=-3*n+9*t-9*r+3*a,h=6*n-12*t+6*r,c=3*t-3*n,f=[];if(p(i,0))p(h,0)||0>(o=-c/h)||o>1||f.push(o);else{var l=h*h-4*i*c;p(l,0)?f.push(-h/(2*i)):l>0&&(e=(-h-(u=Math.sqrt(l)))/(2*i),0>(o=(-h+u)/(2*i))||o>1||f.push(o),0>e||e>1||f.push(e))}return f}function A(n,o,e,u,i,h,c,f,l){if(0===l)return function(n,t){for(var r=0,o=n.length,e=0;o>e;e++)r+=a(n[e],t[e],n[(e+1)%o],t[(e+1)%o]);return r/2}([n,e,i,c],[o,u,h,f]);var s=function(n,t,r,a,o,e,u,i,h){var c=P(n,r,o,u,h),f=P(t,a,e,i,h),l=g(n,t,r,a,h),s=g(r,a,o,e,h),v=g(o,e,u,i,h),p=g(l.x,l.y,s.x,s.y,h),y=g(s.x,s.y,v.x,v.y,h);return[[n,t,l.x,l.y,p.x,p.y,c,f],[c,f,y.x,y.y,v.x,v.y,u,i]]}(n,o,e,u,i,h,c,f,.5),v=r(r([],t(s[0]),!1),[l-1],!1),p=r(r([],t(s[1]),!1),[l-1],!1);return A.apply(void 0,r([],t(v),!1))+A.apply(void 0,r([],t(p),!1))}function I(n,t,r,a,o,e,u,i,h,c,f){return M([n,r,o,u],[t,a,e,i],h,c,P,f)}function q(n){for(var t=0,r=[],o=0;n.length-1>o;o++){var e=n[o],u=n[o+1],i=a(e[0],e[1],u[0],u[1]);r.push({from:e,to:u,length:i}),t+=i}return{segments:r,totalLength:t}}function L(n){if(2>n.length)return 0;for(var t=0,r=0;n.length-1>r;r++){var o=n[r],e=n[r+1];t+=a(o[0],o[1],e[0],e[1])}return t}function T(n,t){if(t>1||0>t||2>n.length)return null;var r=q(n),a=r.segments,o=r.totalLength;if(0===o)return{x:n[0][0],y:n[0][1]};for(var e=0,u=null,i=0;a.length>i;i++){var h=a[i],c=h.from,f=h.to,l=h.length/o;if(t>=e&&e+l>=t){u=g(c[0],c[1],f[0],f[1],(t-e)/l);break}e+=l}return u}function w(n,t){if(t>1||0>t||2>n.length)return 0;for(var r=q(n),a=r.segments,o=r.totalLength,e=0,u=0,i=0;a.length>i;i++){var h=a[i],c=h.from,f=h.to,l=h.length/o;if(t>=e&&e+l>=t){u=Math.atan2(f[1]-c[1],f[0]-c[0]);break}e+=l}return u}function B(n,t,r){for(var a=1/0,o=0;n.length-1>o;o++){var e=n[o],u=n[o+1],i=x(e[0],e[1],u[0],u[1],t,r);a>i&&(a=i)}return a}function D(n){for(var t=[],r=[],a=0;n.length>a;a++){var e=n[a];t.push(e[0]),r.push(e[1])}return o(t,r)}function F(n){var t=n.slice(0);return n.length&&t.push(n[0]),t}function G(n,t,r,a){var o=1-a;return o*o*n+2*a*o*t+a*a*r}function N(n,t,r){var a=n+r-2*t;if(p(a,0))return[.5];var o=(n-t)/a;return o>1||0>o?[]:[o]}function k(n,o,e,u,i,h,c){if(0===c)return(a(n,o,e,u)+a(e,u,i,h)+a(n,o,i,h))/2;var f=function(n,t,r,a,o,e,u){var i=G(n,r,o,u),h=G(t,a,e,u),c=g(n,t,r,a,u),f=g(r,a,o,e,u);return[[n,t,c.x,c.y,i,h],[i,h,f.x,f.y,o,e]]}(n,o,e,u,i,h,.5),l=f[0],s=f[1];return l.push(c-1),s.push(c-1),k.apply(void 0,r([],t(l),!1))+k.apply(void 0,r([],t(s),!1))}function S(n,t,r,a,o,e,u,i){return M([n,r,o],[t,a,e],u,i,G)}n.arcBox=function(n,t,r,a,o,e,u){for(var c=function(n,t,r){return Math.atan(-t/n*Math.tan(r))}(r,a,o),f=1/0,l=-1/0,s=[e,u],v=2*-Math.PI;2*Math.PI>=v;v+=Math.PI){var p=c+v;u>e?p>e&&u>p&&s.push(p):p>u&&e>p&&s.push(p)}for(v=0;s.length>v;v++){var y=i(n,0,r,a,o,s[v]);f>y&&(f=y),y>l&&(l=y)}var M=function(n,t,r){return Math.atan(t/(n*Math.tan(r)))}(r,a,o),g=1/0,x=-1/0,d=[e,u];for(v=2*-Math.PI;2*Math.PI>=v;v+=Math.PI){var P=M+v;u>e?P>e&&u>P&&d.push(P):P>u&&e>P&&d.push(P)}for(v=0;d.length>v;v++){var b=h(0,t,r,a,o,d[v]);g>b&&(g=b),b>x&&(x=b)}return{x:f,y:g,width:l-f,height:x-g}},n.arcNearestPoint=function(n,r,a,o,e,i,h,l,s){var v=t(f(l-n,s-r,-e),2),p=function(n,t,r,a,o,e){var i=r,h=a;if(0===i||0===h)return{x:n,y:t};for(var c=o-n,f=e-t,l=Math.abs(c),s=Math.abs(f),v=i*i,p=h*h,y=Math.PI/4,M=0,g=0,x=0;4>x;x++){M=i*Math.cos(y),g=h*Math.sin(y);var d=(v-p)*Math.pow(Math.cos(y),3)/i,P=(p-v)*Math.pow(Math.sin(y),3)/h,b=M-d,m=g-P,A=l-d,I=s-P,q=Math.hypot(m,b),L=Math.hypot(I,A);y=Math.min(Math.PI/2,Math.max(0,y+=q*Math.asin((b*I-m*A)/(q*L))/Math.sqrt(v+p-M*M-g*g)))}return{x:n+u(M,c),y:t+u(g,f)}}(0,0,a,o,v[0],v[1]),y=function(n,t,r,a){return(Math.atan2(a*n,r*t)+2*Math.PI)%(2*Math.PI)}(a,o,p.x,p.y);i>y?p=c(a,o,i):y>h&&(p=c(a,o,h));var M=f(p.x,p.y,e);return{x:M[0]+n,y:M[1]+r}},n.arcTangentAngle=function(n,t,r,a,o,u,i,h){var c=(i-u)*h+u,f=function(n,t,r,a,o,e,u,i){return-1*r*Math.cos(o)*Math.sin(i)-a*Math.sin(o)*Math.cos(i)}(0,0,r,a,o,0,0,c),l=function(n,t,r,a,o,e,u,i){return-1*r*Math.sin(o)*Math.sin(i)+a*Math.cos(o)*Math.cos(i)}(0,0,r,a,o,0,0,c);return e(Math.atan2(l,f))},n.cubicBox=function(n,t,r,a,e,u,i,h){for(var c=[n,i],f=[t,h],l=m(n,r,e,i),s=m(t,a,u,h),v=0;l.length>v;v++)c.push(P(n,r,e,i,l[v]));for(v=0;s.length>v;v++)f.push(P(t,a,u,h,s[v]));return o(c,f)},n.cubicLength=function(n,t,r,a,o,e,u,i){return A(n,t,r,a,o,e,u,i,3)},n.cubicNearestPoint=I,n.cubicPointAt=function(n,t,r,a,o,e,u,i,h){return{x:P(n,r,o,u,h),y:P(t,a,e,i,h)}},n.cubicPointDistance=function(n,t,r,o,e,u,i,h,c,f,l){var s=I(n,t,r,o,e,u,i,h,c,f,l);return a(s.x,s.y,c,f)},n.cubicTangentAngle=function(n,t,r,a,o,u,i,h,c){var f=b(n,r,o,i,c),l=b(t,a,u,h,c);return e(Math.atan2(l,f))},n.distance=a,n.lineBox=function(n,t,r,a){return o([n,r],[t,a])},n.lineLength=function(n,t,r,o){return a(n,t,r,o)},n.linePointAt=g,n.linePointDistance=x,n.linePointToLine=d,n.lineTangentAngle=function(n,t,r,a){return Math.atan2(a-t,r-n)},n.polygonBox=function(n){return D(n)},n.polygonLength=function(n){return L(F(n))},n.polygonPointAt=function(n,t){return T(F(n),t)},n.polygonPointDistance=function(n,t,r){return B(F(n),t,r)},n.polygonTangentAngle=function(n,t){return w(F(n),t)},n.polylineBox=D,n.polylineLength=function(n){return L(n)},n.polylinePointAt=function(n,t){return T(n,t)},n.polylinePointDistance=function(n,t,r){return B(n,t,r)},n.polylineTangentAngle=function(n,t){return w(n,t)},n.quadBox=function(n,t,r,a,e,u){var i=N(n,r,e)[0],h=N(t,a,u)[0],c=[n,e],f=[t,u];return void 0!==i&&c.push(G(n,r,e,i)),void 0!==h&&f.push(G(t,a,u,h)),o(c,f)},n.quadLength=function(n,t,r,a,o,e){return k(n,t,r,a,o,e,3)},n.quadNearestPoint=S,n.quadPointDistance=function(n,t,r,o,e,u,i,h){var c=S(n,t,r,o,e,u,i,h);return a(c.x,c.y,i,h)}}));
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((n="undefined"!=typeof globalThis?globalThis:n||self).G=n.G||{},n.G.Math={}))}(this,(function(n){"use strict";function t(n,t){var r="function"==typeof Symbol&&n[Symbol.iterator];if(!r)return n;var a,o,e=r.call(n),u=[];try{for(;(void 0===t||t-- >0)&&!(a=e.next()).done;)u.push(a.value)}catch(n){o={error:n}}finally{try{a&&!a.done&&(r=e.return)&&r.call(e)}finally{if(o)throw o.error}}return u}function r(n,t,r){if(r||2===arguments.length)for(var a,o=0,e=t.length;e>o;o++)!a&&o in t||(a||(a=Array.prototype.slice.call(t,0,o)),a[o]=t[o]);return n.concat(a||Array.prototype.slice.call(t))}function a(n,t,r,a){var o=n-r,e=t-a;return Math.sqrt(o*o+e*e)}function o(n,a){var o=Math.min.apply(Math,r([],t(n),!1)),e=Math.min.apply(Math,r([],t(a),!1));return{x:o,y:e,width:Math.max.apply(Math,r([],t(n),!1))-o,height:Math.max.apply(Math,r([],t(a),!1))-e}}function e(n){return(n+2*Math.PI)%(2*Math.PI)}function u(n,t){var r=Math.abs(n);return t>0?r:-1*r}function i(n,t,r,a,o,e){return r*Math.cos(o)*Math.cos(e)-a*Math.sin(o)*Math.sin(e)+n}function h(n,t,r,a,o,e){return r*Math.sin(o)*Math.cos(e)+a*Math.cos(o)*Math.sin(e)+t}function c(n,t,r){return{x:n*Math.cos(r),y:t*Math.sin(r)}}function f(n,t,r){var a=Math.cos(r),o=Math.sin(r);return[n*a-t*o,n*o+t*a]}var l=1e-5;function s(n,t,r){return void 0===r&&(r=l),r>Math.abs(n-t)}var v,p="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var n=0,t=arguments.length;t--;)n+=arguments[t]*arguments[t];return Math.sqrt(n)}),v=new p(2),p!=Float32Array&&(v[0]=0,v[1]=0);var y=1e-4;function M(n,o,e,u,i,h){var c=-1,f=1/0,l=[e,u],s=20;h&&h>200&&(s=h/10);for(var v=1/s,p=v/10,M=0;s>=M;M++){var g=M*v,x=[i.apply(void 0,r([],t(n.concat([g])),!1)),i.apply(void 0,r([],t(o.concat([g])),!1))];f>(m=a(l[0],l[1],x[0],x[1]))&&(c=g,f=m)}if(0===c)return{x:n[0],y:o[0]};if(1===c){var d=n.length;return{x:n[d-1],y:o[d-1]}}f=1/0;for(M=0;32>M&&y<=p;M++){var P=c-p,b=c+p,m=(x=[i.apply(void 0,r([],t(n.concat([P])),!1)),i.apply(void 0,r([],t(o.concat([P])),!1))],a(l[0],l[1],x[0],x[1]));if(P>=0&&f>m)c=P,f=m;else{var A=[i.apply(void 0,r([],t(n.concat([b])),!1)),i.apply(void 0,r([],t(o.concat([b])),!1))],I=a(l[0],l[1],A[0],A[1]);1>=b&&f>I?(c=b,f=I):p*=.5}}return{x:i.apply(void 0,r([],t(n.concat([c])),!1)),y:i.apply(void 0,r([],t(o.concat([c])),!1))}}function g(n,t,r,a,o){return{x:(1-o)*n+o*r,y:(1-o)*t+o*a}}function x(n,t,r,o,e,u){var i=(r-n)*(e-n)+(o-t)*(u-t);return 0>i?a(n,t,e,u):i>(r-n)*(r-n)+(o-t)*(o-t)?a(r,o,e,u):d(n,t,r,o,e,u)}function d(n,t,r,a,o,e){var u=[r-n,a-t];if(function(n,t){return n[0]===t[0]&&n[1]===t[1]}(u,[0,0]))return Math.sqrt((o-n)*(o-n)+(e-t)*(e-t));var i=[-u[1],u[0]];return function(n,t){var r=t[0],a=t[1],o=r*r+a*a;o>0&&(o=1/Math.sqrt(o)),n[0]=t[0]*o,n[1]=t[1]*o}(i,i),Math.abs(function(n,t){return n[0]*t[0]+n[1]*t[1]}([o-n,e-t],i))}function P(n,t,r,a,o){var e=1-o;return e*e*e*n+3*t*o*e*e+3*r*o*o*e+a*o*o*o}function b(n,t,r,a,o){var e=1-o;return 3*(e*e*(t-n)+2*e*o*(r-t)+o*o*(a-r))}function m(n,t,r,a){var o,e,u,i=-3*n+9*t-9*r+3*a,h=6*n-12*t+6*r,c=3*t-3*n,f=[];if(s(i,0))s(h,0)||0>(o=-c/h)||o>1||f.push(o);else{var l=h*h-4*i*c;s(l,0)?f.push(-h/(2*i)):l>0&&(e=(-h-(u=Math.sqrt(l)))/(2*i),0>(o=(-h+u)/(2*i))||o>1||f.push(o),0>e||e>1||f.push(e))}return f}function A(n,o,e,u,i,h,c,f,l){if(0===l)return function(n,t){for(var r=0,o=n.length,e=0;o>e;e++)r+=a(n[e],t[e],n[(e+1)%o],t[(e+1)%o]);return r/2}([n,e,i,c],[o,u,h,f]);var s=function(n,t,r,a,o,e,u,i,h){var c=P(n,r,o,u,h),f=P(t,a,e,i,h),l=g(n,t,r,a,h),s=g(r,a,o,e,h),v=g(o,e,u,i,h),p=g(l.x,l.y,s.x,s.y,h),y=g(s.x,s.y,v.x,v.y,h);return[[n,t,l.x,l.y,p.x,p.y,c,f],[c,f,y.x,y.y,v.x,v.y,u,i]]}(n,o,e,u,i,h,c,f,.5),v=r(r([],t(s[0]),!1),[l-1],!1),p=r(r([],t(s[1]),!1),[l-1],!1);return A.apply(void 0,r([],t(v),!1))+A.apply(void 0,r([],t(p),!1))}function I(n,t,r,a,o,e,u,i,h,c,f){return M([n,r,o,u],[t,a,e,i],h,c,P,f)}function q(n){for(var t=0,r=[],o=0;n.length-1>o;o++){var e=n[o],u=n[o+1],i=a(e[0],e[1],u[0],u[1]);r.push({from:e,to:u,length:i}),t+=i}return{segments:r,totalLength:t}}function L(n){if(2>n.length)return 0;for(var t=0,r=0;n.length-1>r;r++){var o=n[r],e=n[r+1];t+=a(o[0],o[1],e[0],e[1])}return t}function T(n,t){if(t>1||0>t||2>n.length)return null;var r=q(n),a=r.segments,o=r.totalLength;if(0===o)return{x:n[0][0],y:n[0][1]};for(var e=0,u=null,i=0;a.length>i;i++){var h=a[i],c=h.from,f=h.to,l=h.length/o;if(t>=e&&e+l>=t){u=g(c[0],c[1],f[0],f[1],(t-e)/l);break}e+=l}return u}function w(n,t){if(t>1||0>t||2>n.length)return 0;for(var r=q(n),a=r.segments,o=r.totalLength,e=0,u=0,i=0;a.length>i;i++){var h=a[i],c=h.from,f=h.to,l=h.length/o;if(t>=e&&e+l>=t){u=Math.atan2(f[1]-c[1],f[0]-c[0]);break}e+=l}return u}function B(n,t,r){for(var a=1/0,o=0;n.length-1>o;o++){var e=n[o],u=n[o+1],i=x(e[0],e[1],u[0],u[1],t,r);a>i&&(a=i)}return a}function D(n){for(var t=[],r=[],a=0;n.length>a;a++){var e=n[a];t.push(e[0]),r.push(e[1])}return o(t,r)}function F(n){var t=n.slice(0);return n.length&&t.push(n[0]),t}function G(n,t,r,a){var o=1-a;return o*o*n+2*a*o*t+a*a*r}function N(n,t,r){var a=n+r-2*t;if(s(a,0))return[.5];var o=(n-t)/a;return o>1||0>o?[]:[o]}function k(n,o,e,u,i,h,c){if(0===c)return(a(n,o,e,u)+a(e,u,i,h)+a(n,o,i,h))/2;var f=function(n,t,r,a,o,e,u){var i=G(n,r,o,u),h=G(t,a,e,u),c=g(n,t,r,a,u),f=g(r,a,o,e,u);return[[n,t,c.x,c.y,i,h],[i,h,f.x,f.y,o,e]]}(n,o,e,u,i,h,.5),l=f[0],s=f[1];return l.push(c-1),s.push(c-1),k.apply(void 0,r([],t(l),!1))+k.apply(void 0,r([],t(s),!1))}function S(n,t,r,a,o,e,u,i){return M([n,r,o],[t,a,e],u,i,G)}n.arcBox=function(n,t,r,a,o,e,u){for(var c=function(n,t,r){return Math.atan(-t/n*Math.tan(r))}(r,a,o),f=1/0,l=-1/0,s=[e,u],v=2*-Math.PI;2*Math.PI>=v;v+=Math.PI){var p=c+v;u>e?p>e&&u>p&&s.push(p):p>u&&e>p&&s.push(p)}for(v=0;s.length>v;v++){var y=i(n,0,r,a,o,s[v]);f>y&&(f=y),y>l&&(l=y)}var M=function(n,t,r){return Math.atan(t/(n*Math.tan(r)))}(r,a,o),g=1/0,x=-1/0,d=[e,u];for(v=2*-Math.PI;2*Math.PI>=v;v+=Math.PI){var P=M+v;u>e?P>e&&u>P&&d.push(P):P>u&&e>P&&d.push(P)}for(v=0;d.length>v;v++){var b=h(0,t,r,a,o,d[v]);g>b&&(g=b),b>x&&(x=b)}return{x:f,y:g,width:l-f,height:x-g}},n.arcNearestPoint=function(n,r,a,o,e,i,h,l,s){var v=t(f(l-n,s-r,-e),2),p=function(n,t,r,a,o,e){var i=r,h=a;if(0===i||0===h)return{x:n,y:t};for(var c=o-n,f=e-t,l=Math.abs(c),s=Math.abs(f),v=i*i,p=h*h,y=Math.PI/4,M=0,g=0,x=0;4>x;x++){M=i*Math.cos(y),g=h*Math.sin(y);var d=(v-p)*Math.pow(Math.cos(y),3)/i,P=(p-v)*Math.pow(Math.sin(y),3)/h,b=M-d,m=g-P,A=l-d,I=s-P,q=Math.hypot(m,b),L=Math.hypot(I,A);y=Math.min(Math.PI/2,Math.max(0,y+=q*Math.asin((b*I-m*A)/(q*L))/Math.sqrt(v+p-M*M-g*g)))}return{x:n+u(M,c),y:t+u(g,f)}}(0,0,a,o,v[0],v[1]),y=function(n,t,r,a){return(Math.atan2(a*n,r*t)+2*Math.PI)%(2*Math.PI)}(a,o,p.x,p.y);i>y?p=c(a,o,i):y>h&&(p=c(a,o,h));var M=f(p.x,p.y,e);return{x:M[0]+n,y:M[1]+r}},n.arcTangentAngle=function(n,t,r,a,o,u,i,h){var c=(i-u)*h+u,f=function(n,t,r,a,o,e,u,i){return-1*r*Math.cos(o)*Math.sin(i)-a*Math.sin(o)*Math.cos(i)}(0,0,r,a,o,0,0,c),l=function(n,t,r,a,o,e,u,i){return-1*r*Math.sin(o)*Math.sin(i)+a*Math.cos(o)*Math.cos(i)}(0,0,r,a,o,0,0,c);return e(Math.atan2(l,f))},n.cubicBox=function(n,t,r,a,e,u,i,h){for(var c=[n,i],f=[t,h],l=m(n,r,e,i),s=m(t,a,u,h),v=0;l.length>v;v++)c.push(P(n,r,e,i,l[v]));for(v=0;s.length>v;v++)f.push(P(t,a,u,h,s[v]));return o(c,f)},n.cubicLength=function(n,t,r,a,o,e,u,i){return A(n,t,r,a,o,e,u,i,3)},n.cubicNearestPoint=I,n.cubicPointAt=function(n,t,r,a,o,e,u,i,h){return{x:P(n,r,o,u,h),y:P(t,a,e,i,h)}},n.cubicPointDistance=function(n,t,r,o,e,u,i,h,c,f,l){var s=I(n,t,r,o,e,u,i,h,c,f,l);return a(s.x,s.y,c,f)},n.cubicTangentAngle=function(n,t,r,a,o,u,i,h,c){var f=b(n,r,o,i,c),l=b(t,a,u,h,c);return e(Math.atan2(l,f))},n.distance=a,n.lineBox=function(n,t,r,a){return o([n,r],[t,a])},n.lineLength=function(n,t,r,o){return a(n,t,r,o)},n.linePointAt=g,n.linePointDistance=x,n.linePointToLine=d,n.lineTangentAngle=function(n,t,r,a){return Math.atan2(a-t,r-n)},n.polygonBox=function(n){return D(n)},n.polygonLength=function(n){return L(F(n))},n.polygonPointAt=function(n,t){return T(F(n),t)},n.polygonPointDistance=function(n,t,r){return B(F(n),t,r)},n.polygonTangentAngle=function(n,t){return w(F(n),t)},n.polylineBox=D,n.polylineLength=function(n){return L(n)},n.polylinePointAt=function(n,t){return T(n,t)},n.polylinePointDistance=function(n,t,r){return B(n,t,r)},n.polylineTangentAngle=function(n,t){return w(n,t)},n.quadBox=function(n,t,r,a,e,u){var i=N(n,r,e)[0],h=N(t,a,u)[0],c=[n,e],f=[t,u];return void 0!==i&&c.push(G(n,r,e,i)),void 0!==h&&f.push(G(t,a,u,h)),o(c,f)},n.quadLength=function(n,t,r,a,o,e){return k(n,t,r,a,o,e,3)},n.quadNearestPoint=S,n.quadPointDistance=function(n,t,r,o,e,u,i,h){var c=S(n,t,r,o,e,u,i,h);return a(c.x,c.y,i,h)}}));
//# sourceMappingURL=index.umd.min.js.map
{
"name": "@antv/g-math",
"version": "2.0.2",
"version": "2.0.3-next.0",
"description": "Geometry util",

@@ -35,3 +35,3 @@ "keywords": [

"dependencies": {
"@antv/util": "^3.3.4",
"@antv/util": "^3.3.5",
"gl-matrix": "^3.4.3",

@@ -38,0 +38,0 @@ "tslib": "^2.5.3"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc