You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
9.5 KiB

4 months ago
/*!
* @antv/g-math
* @description Geometry util
* @version 3.0.1
* @date 5/9/2025, 8:18:51 AM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.Math={}))}(this,(function(t){"use strict";function n(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,a=Array(n);n>r;r++)a[r]=t[r];return a}function r(t,r){if(t){if("string"==typeof t)return n(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?n(t,r):void 0}}function a(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var a,e,o,u,i=[],c=!0,f=!1;try{if(o=(r=r.call(t)).next,0===n){if(Object(r)!==r)return;c=!1}else for(;!(c=(a=o.call(r)).done)&&(i.push(a.value),i.length!==n);c=!0);}catch(t){f=!0,e=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(f)throw e}}return i}}(t,n)||r(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||r(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,n,r,a){var e=t-r,o=n-a;return Math.sqrt(e*e+o*o)}function u(t,n){var r=Math.min.apply(Math,e(t)),a=Math.min.apply(Math,e(n));return{x:r,y:a,width:Math.max.apply(Math,e(t))-r,height:Math.max.apply(Math,e(n))-a}}function i(t){return(t+2*Math.PI)%(2*Math.PI)}function c(t,n){var r=Math.abs(t);return n>0?r:-1*r}function f(t,n,r,a,e,o){return r*Math.cos(e)*Math.cos(o)-a*Math.sin(e)*Math.sin(o)+t}function h(t,n,r,a,e,o){return r*Math.sin(e)*Math.cos(o)+a*Math.cos(e)*Math.sin(o)+n}function l(t,n,r){return{x:t*Math.cos(r),y:n*Math.sin(r)}}function s(t,n,r){var a=Math.cos(r),e=Math.sin(r);return[t*a-n*e,t*e+n*a]}function y(t,n,r){return void 0===r&&(r=1e-5),t===n||r>Math.abs(t-n)}var v,p="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var t=0,n=arguments.length;n--;)t+=arguments[n]*arguments[n];return Math.sqrt(t)}),v=new p(2),p!=Float32Array&&(v[0]=0,v[1]=0);function M(t,n,r,a,u,i){var c=-1,f=1/0,h=[r,a],l=20;i&&i>200&&(l=i/10);for(var s=1/l,y=s/10,v=0;l>=v;v++){var p=v*s,M=[u.apply(void 0,e(t.concat([p]))),u.apply(void 0,e(n.concat([p])))],g=o(h[0],h[1],M[0],M[1]);f>g&&(c=p,f=g)}if(0===c)return{x:t[0],y:n[0]};if(1===c){var d=t.length;return{x:t[d-1],y:n[d-1]}}f=1/0;for(var x=0;32>x&&1e-4<=y;x++){var b=c-y,m=c+y,P=[u.apply(void 0,e(t.concat([b]))),u.apply(void 0,e(n.concat([b])))],A=o(h[0],h[1],P[0],P[1]);if(b>=0&&f>A)c=b,f=A;else{var I=[u.apply(void 0,e(t.concat([m]))),u.apply(void 0,e(n.concat([m])))],q=o(h[0],h[1],I[0],I[1]);1>=m&&f>q?(c=m,f=q):y*=.5}}return{x:u.apply(void 0,e(t.concat([c]))),y:u.apply(void 0,e(n.concat([c])))}}function g(t,n,r,a,e){return{x:(1-e)*t+e*r,y:(1-e)*n+e*a}}function d(t,n,r,a,e,u){var i=(r-t)*(e-t)+(a-n)*(u-n);return 0>i?o(t,n,e,u):i>(r-t)*(r-t)+(a-n)*(a-n)?o(r,a,e,u):x(t,n,r,a,e,u)}function x(t,n,r,a,e,o){var u=[r-t,a-n];if(function(t,n){return t[0]===n[0]&&t[1]===n[1]}(u,[0,0]))return Math.sqrt((e-t)*(e-t)+(o-n)*(o-n));var i=[-u[1],u[0]];return function(t,n){var r=n[0],a=n[1],e=r*r+a*a;e>0&&(e=1/Math.sqrt(e)),t[0]=n[0]*e,t[1]=n[1]*e}(i,i),Math.abs(function(t,n){return t[0]*n[0]+t[1]*n[1]}([e-t,o-n],i))}function b(t,n,r,a,e){var o=1-e;return o*o*o*t+3*n*e*o*o+3*r*e*e*o+a*e*e*e}function m(t,n,r,a,e){var o=1-e;return 3*(o*o*(n-t)+2*o*e*(r-n)+e*e*(a-r))}function P(t,n,r,a){var e,o,u,i=-3*t+9*n-9*r+3*a,c=6*t-12*n+6*r,f=3*n-3*t,h=[];if(y(i,0))y(c,0)||0>(e=-f/c)||e>1||h.push(e);else{var l=c*c-4*i*f;y(l,0)?h.push(-c/(2*i)):l>0&&(o=(-c-(u=M
//# sourceMappingURL=index.umd.min.js.map