2 lines
10 KiB
JavaScript
2 lines
10 KiB
JavaScript
!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).predicates={})}(this,(function(t){"use strict";const n=11102230246251565e-32,e=134217729,o=(3+8*n)*n;function f(t,n,e,o,f){let i,r,c,s,u=n[0],a=o[0],l=0,b=0;a>u==a>-u?(i=u,u=n[++l]):(i=a,a=o[++b]);let d=0;if(l<t&&b<e)for(a>u==a>-u?(r=u+i,c=i-(r-u),u=n[++l]):(r=a+i,c=i-(r-a),a=o[++b]),i=r,0!==c&&(f[d++]=c);l<t&&b<e;)a>u==a>-u?(r=i+u,s=r-i,c=i-(r-s)+(u-s),u=n[++l]):(r=i+a,s=r-i,c=i-(r-s)+(a-s),a=o[++b]),i=r,0!==c&&(f[d++]=c);for(;l<t;)r=i+u,s=r-i,c=i-(r-s)+(u-s),u=n[++l],i=r,0!==c&&(f[d++]=c);for(;b<e;)r=i+a,s=r-i,c=i-(r-s)+(a-s),a=o[++b],i=r,0!==c&&(f[d++]=c);return 0===i&&0!==d||(f[d++]=i),d}function i(t,n,e,o,i,r,c,s){return f(f(t,n,e,o,c),c,i,r,s)}function r(t,n,o,f){let i,r,c,s,u,a,l,b,d,h,p;l=e*o,h=l-(l-o),p=o-h;let M=n[0];i=M*o,l=e*M,b=l-(l-M),d=M-b,c=d*p-(i-b*h-d*h-b*p);let y=0;0!==c&&(f[y++]=c);for(let x=1;x<t;x++)M=n[x],s=M*o,l=e*M,b=l-(l-M),d=M-b,u=d*p-(s-b*h-d*h-b*p),r=i+u,a=r-i,c=i-(r-a)+(u-a),0!==c&&(f[y++]=c),i=s+r,c=r-(i-s),0!==c&&(f[y++]=c);return 0===i&&0!==y||(f[y++]=i),y}function c(t){return new Float64Array(t)}const s=4440892098500632e-31,u=5423418723394464e-46,a=c(4),l=c(4),b=c(4),d=c(4),h=c(4),p=c(4),M=c(4),y=c(4),x=c(8),g=c(8),m=c(8),T=c(8),j=c(8),w=c(8),A=c(8),F=c(8),k=c(8),q=c(4),v=c(4),z=c(4),B=c(8),C=c(16),D=c(16),E=c(16),G=c(32),H=c(32),I=c(48),J=c(64);let K=c(1152),L=c(1152);function N(t,n,e){t=f(t,K,n,e,L);const o=K;return K=L,L=o,t}t.incircle=function(t,n,c,L,O,P,Q,R){const S=t-Q,U=c-Q,V=O-Q,W=n-R,X=L-R,Y=P-R,Z=U*Y,$=V*X,_=S*S+W*W,tt=V*W,nt=S*Y,et=U*U+X*X,ot=S*X,ft=U*W,it=V*V+Y*Y,rt=_*(Z-$)+et*(tt-nt)+it*(ot-ft),ct=(Math.abs(Z)+Math.abs($))*_+(Math.abs(tt)+Math.abs(nt))*et+(Math.abs(ot)+Math.abs(ft))*it,st=11102230246251577e-31*ct;return rt>st||-rt>st?rt:function(t,n,c,L,O,P,Q,R,S){let U,V,W,X,Y,Z,$,_,tt,nt,et,ot,ft,it,rt,ct,st,ut,at,lt,bt,dt,ht,pt,Mt,yt,xt,gt,mt,Tt,jt,wt,At,Ft,kt;const qt=t-Q,vt=c-Q,zt=O-Q,Bt=n-R,Ct=L-R,Dt=P-R;jt=vt*Dt,ht=e*vt,pt=ht-(ht-vt),Mt=vt-pt,ht=e*Dt,yt=ht-(ht-Dt),xt=Dt-yt,wt=Mt*xt-(jt-pt*yt-Mt*yt-pt*xt),At=zt*Ct,ht=e*zt,pt=ht-(ht-zt),Mt=zt-pt,ht=e*Ct,yt=ht-(ht-Ct),xt=Ct-yt,Ft=Mt*xt-(At-pt*yt-Mt*yt-pt*xt),gt=wt-Ft,dt=wt-gt,a[0]=wt-(gt+dt)+(dt-Ft),mt=jt+gt,dt=mt-jt,Tt=jt-(mt-dt)+(gt-dt),gt=Tt-At,dt=Tt-gt,a[1]=Tt-(gt+dt)+(dt-At),kt=mt+gt,dt=kt-mt,a[2]=mt-(kt-dt)+(gt-dt),a[3]=kt,jt=zt*Bt,ht=e*zt,pt=ht-(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