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,r=(3+8*n)*n;function o(t,n,e,r,o){let a,s,f,u,i=n[0],c=r[0],h=0,b=0;c>i==c>-i?(a=i,i=n[++h]):(a=c,c=r[++b]);let l=0;if(h<t&&b<e)for(c>i==c>-i?(s=i+a,f=a-(s-i),i=n[++h]):(s=c+a,f=a-(s-c),c=r[++b]),a=s,0!==f&&(o[l++]=f);h<t&&b<e;)c>i==c>-i?(s=a+i,u=s-a,f=a-(s-u)+(i-u),i=n[++h]):(s=a+c,u=s-a,f=a-(s-u)+(c-u),c=r[++b]),a=s,0!==f&&(o[l++]=f);for(;h<t;)s=a+i,u=s-a,f=a-(s-u)+(i-u),i=n[++h],a=s,0!==f&&(o[l++]=f);for(;b<e;)s=a+c,u=s-a,f=a-(s-u)+(c-u),c=r[++b],a=s,0!==f&&(o[l++]=f);return 0===a&&0!==l||(o[l++]=a),l}function a(t,n,e,r,a,s,f,u){return o(o(t,n,e,r,f),f,a,s,u)}function s(t,n,r,o){let a,s,f,u,i,c,h,b,l,M,d;h=e*r,M=h-(h-r),d=r-M;let p=n[0];a=p*r,h=e*p,b=h-(h-p),l=p-b,f=l*d-(a-b*M-l*M-b*d);let y=0;0!==f&&(o[y++]=f);for(let x=1;x<t;x++)p=n[x],u=p*r,h=e*p,b=h-(h-p),l=p-b,i=l*d-(u-b*M-l*M-b*d),s=a+i,c=s-a,f=a-(s-c)+(i-c),0!==f&&(o[y++]=f),a=u+s,f=s-(a-u),0!==f&&(o[y++]=f);return 0===a&&0!==y||(o[y++]=a),y}function f(t,n){for(let e=0;e<t;e++)n[e]=-n[e];return t}function u(t){return new Float64Array(t)}const i=5551115123125792e-31,c=8751425667295619e-46,h=u(4),b=u(4),l=u(4),M=u(4),d=u(4),p=u(4),y=u(4),x=u(4),g=u(4),m=u(4),T=u(24),j=u(24),w=u(24),A=u(24),F=u(24),k=u(24),q=u(24),v=u(24),z=u(24),B=u(24),C=u(1152),D=u(1152),E=u(1152),G=u(1152),H=u(1152),I=u(2304),J=u(2304),K=u(3456),L=u(5760),N=u(8),O=u(8),P=u(8),Q=u(16),R=u(24),S=u(48),U=u(48),V=u(96),W=u(192),X=u(384),Y=u(384),Z=u(384),$=u(768);function _(t,n,e,r,o,f,u){return a(s(4,t,r,N),N,s(4,n,o,O),O,s(4,e,f,P),P,Q,u)}function tt(t,n,e,r,u,i,c,h,b,l,M,d){const p=o(o(t,n,e,r,S),S,f(o(u,i,c,h,U),U),U,V);return a(s(s(p,V,b,W),W,b,X),X,s(s(p,V,l,W),W,l,Y),Y,s(s(p,V,M,W),W,M,Z),Z,$,d)}const nt=u(96),et=u(96),rt=u(96),ot=u(1152);function at(t,n,e,r,o,f,u,i,c,h){const b=_(t,n,e,r,o,f,R);return a(s(s(b,R,u,S),S,u,nt),nt,s(s(b,R,i,S),S,i,et),et,s(s(b,R,c,S),S,c,rt),rt,W,h)}function st(t,n,s,u,N,O,P,Q,R,S,U,V,W,X,Y,Z){let $,nt,et,rt,st,ft,ut,it,ct,ht,bt,lt,Mt,dt,pt,yt,xt,gt,mt,Tt,jt,wt,At,Ft,kt,qt,vt,zt,Bt,Ct,Dt;const Et=t-W,Gt=u-W,Ht=P-W,It=S-W,Jt=n-X,Kt=N-X,Lt=Q-X,Nt=U-X,Ot=s-Y,Pt=O-Y,Qt=R-Y,Rt=V-Y;zt=Et*Kt,Tt=e*Et,jt=Tt-(Tt-Et),wt=Et-jt,Tt=e*Kt,At=Tt-(Tt-Kt),Ft=Kt-At,Bt=wt*Ft-(zt-jt*At-wt*At-jt*Ft),Ct=Gt*Jt,Tt=e*Gt,jt=Tt-(Tt-Gt),wt=Gt-jt,Tt=e*Jt,At=Tt-(Tt-Jt),Ft=Jt-At,Dt=wt*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Q,S=d*d+g*g+w*w,U=p*p+m*m+A*A,V=y*y+T*T+F*F,W=x*x+j*j+k*k,X=V*(k*z+w*R+A*K)-W*(w*D-A*O+F*z)+(S*(A*H-F*R+k*D)-U*(F*K+k*O+w*H)),Y=Math.abs(w),Z=Math.abs(A),$=Math.abs(F),_=Math.abs(k),tt=Math.abs(q)+Math.abs(v),nt=Math.abs(B)+Math.abs(C),et=Math.abs(E)+Math.abs(G),rt=Math.abs(I)+Math.abs(J),ot=Math.abs(L)+Math.abs(N),at=Math.abs(P)+Math.abs(Q),ft=(et*Z+at*$+nt*_)*S+(rt*$+ot*_+et*Y)*U+(tt*_+at*Y+rt*Z)*V+(nt*Y+ot*Z+tt*$)*W,ut=17763568394002532e-31*ft;return X>ut||-X>ut?X:-st(t,n,e,r,o,a,s,f,u,i,c,h,b,l,M,ft)},t.inspherefast=function(t,n,e,r,o,a,s,f,u,i,c,h,b,l,M){const d=t-b,p=r-b,y=s-b,x=i-b,g=n-l,m=o-l,T=f-l,j=c-l,w=e-M,A=a-M,F=u-M,k=h-M,q=d*m-p*g,v=p*T-y*m,z=y*j-x*T,B=x*g-d*j,C=d*T-y*g,D=p*j-x*m;return(y*y+T*T+F*F)*(k*q+w*D+A*B)-(x*x+j*j+k*k)*(w*v-A*C+F*q)+((d*d+g*g+w*w)*(A*z-F*D+k*v)-(p*p+m*m+A*A)*(F*B+k*C+w*z))}}));
|