Lin_Ye_Fang_Huo/public/lib/Cesium/Workers/IntersectionTests-93a038e3.js

2 lines
13 KiB
JavaScript
Raw Normal View History

2023-07-18 09:04:15 +08:00
define(["exports","./Matrix2-e6265fb0","./defaultValue-69ee94f4","./RuntimeError-ac440aa5","./Transforms-c84edde7","./ComponentDatatype-a9820060"],(function(t,e,n,a,i,r){"use strict";const s={};function o(t,e,n){const a=t+e;return r.CesiumMath.sign(t)!==r.CesiumMath.sign(e)&&Math.abs(a/Math.max(Math.abs(t),Math.abs(e)))<n?0:a}s.computeDiscriminant=function(t,e,n){return e*e-4*t*n},s.computeRealRoots=function(t,e,n){let a;if(0===t)return 0===e?[]:[-n/e];if(0===e){if(0===n)return[0,0];const e=Math.abs(n),i=Math.abs(t);if(e<i&&e/i<r.CesiumMath.EPSILON14)return[0,0];if(e>i&&i/e<r.CesiumMath.EPSILON14)return[];if(a=-n/t,a<0)return[];const s=Math.sqrt(a);return[-s,s]}if(0===n)return a=-e/t,a<0?[a,0]:[0,a];const i=o(e*e,-(4*t*n),r.CesiumMath.EPSILON14);if(i<0)return[];const s=-.5*o(e,r.CesiumMath.sign(e)*Math.sqrt(i),r.CesiumMath.EPSILON14);return e>0?[s/t,n/s]:[n/s,s/t]};const c={};function u(t,e,n,a){const i=t,r=e/3,s=n/3,o=a,c=i*s,u=r*o,l=r*r,C=s*s,M=i*s-l,h=i*o-r*s,m=r*o-C,f=4*M*m-h*h;let d,g;if(f<0){let t,e,n;l*u>=c*C?(t=i,e=M,n=-2*r*M+i*h):(t=o,e=m,n=-o*h+2*s*m);const a=-(n<0?-1:1)*Math.abs(t)*Math.sqrt(-f);g=-n+a;const p=g/2,w=p<0?-Math.pow(-p,1/3):Math.pow(p,1/3),R=g===a?-w:-e/w;return d=e<=0?w+R:-n/(w*w+R*R+e),l*u>=c*C?[(d-r)/i]:[-o/(d+s)]}const p=M,w=-2*r*M+i*h,R=m,S=-o*h+2*s*m,O=Math.sqrt(f),x=Math.sqrt(3)/2;let y=Math.abs(Math.atan2(i*O,-w)/3);d=2*Math.sqrt(-p);let P=Math.cos(y);g=d*P;let N=d*(-P/2-x*Math.sin(y));const b=g+N>2*r?g-r:N-r,q=i,L=b/q;y=Math.abs(Math.atan2(o*O,-S)/3),d=2*Math.sqrt(-R),P=Math.cos(y),g=d*P,N=d*(-P/2-x*Math.sin(y));const I=-o,E=g+N<2*s?g+s:N+s,z=I/E,T=-b*E-q*I,v=(s*T-r*(b*I))/(-r*T+s*(q*E));return L<=v?L<=z?v<=z?[L,v,z]:[L,z,v]:[z,L,v]:L<=z?[v,L,z]:v<=z?[v,z,L]:[z,v,L]}c.computeDiscriminant=function(t,e,n,a){const i=e*e,r=n*n;return 18*t*e*n*a+i*r-27*(t*t)*(a*a)-4*(t*r*n+i*e*a)},c.computeRealRoots=function(t,e,n,a){let i,r;if(0===t)return s.computeRealRoots(e,n,a);if(0===e){if(0===n){if(0===a)return[0,0,0];r=-a/t;const e=r<0?-Math.pow(-r,1/3):Math.pow(r,1/3);return[e,e,e]}return 0===a?(i=s.computeRealRoots(t,0,n),0===i.Length?[0]:[i[0],0,i[1]]):u(t,0,n,a)}return 0===n?0===a?(r=-e/t,r<0?[r,0,0]:[0,0,r]):u(t,e,0,a):0===a?(i=s.computeRealRoots(t,e,n),0===i.length?[0]:i[1]<=0?[i[0],i[1],0]:i[0]>=0?[0,i[0],i[1]]:[i[0],0,i[1]]):u(t,e,n,a)};const l={};function C(t,e,n,a){const i=t*t,o=e-3*i/8,u=n-e*t/2+i*t/8,l=a-n*t/4+e*i/16-3*i*i/256,C=c.computeRealRoots(1,2*o,o*o-4*l,-u*u);if(C.length>0){const e=-t/4,n=C[C.length-1];if(Math.abs(n)<r.CesiumMath.EPSILON14){const t=s.computeRealRoots(1,o,l);if(2===t.length){const n=t[0],a=t[1];let i;if(n>=0&&a>=0){const t=Math.sqrt(n),i=Math.sqrt(a);return[e-i,e-t,e+t,e+i]}if(n>=0&&a<0)return i=Math.sqrt(n),[e-i,e+i];if(n<0&&a>=0)return i=Math.sqrt(a),[e-i,e+i]}return[]}if(n>0){const t=Math.sqrt(n),a=(o+n-u/t)/2,i=(o+n+u/t)/2,r=s.computeRealRoots(1,t,a),c=s.computeRealRoots(1,-t,i);return 0!==r.length?(r[0]+=e,r[1]+=e,0!==c.length?(c[0]+=e,c[1]+=e,r[1]<=c[0]?[r[0],r[1],c[0],c[1]]:c[1]<=r[0]?[c[0],c[1],r[0],r[1]]:r[0]>=c[0]&&r[1]<=c[1]?[c[0],r[0],r[1],c[1]]:c[0]>=r[0]&&c[1]<=r[1]?[r[0],c[0],c[1],r[1]]:r[0]>c[0]&&r[0]<c[1]?[c[0],r[0],c[1],r[1]]:[r[0],c[0],r[1],c[1]]):r):0!==c.length?(c[0]+=e,c[1]+=e,c):[]}}return[]}function M(t,e,n,a){const i=t*t,o=-2*e,u=n*t+e*e-4*a,l=i*a-n*e*t+n*n,C=c.computeRealRoots(1,o,u,l);if(C.length>0){const o=C[0],c=e-o,u=c*c,l=t/2,M=c/2,h=u-4*a,m=u+4*Math.abs(a),f=i-4*o,d=i+4*Math.abs(o);let g,p,w,R,S,O;if(o<0||h*d<f*m){const e=Math.sqrt(f);g=e/2,p=0===e?0:(t*M-n)/e}else{const e=Math.sqrt(h);g=0===e?0:(t*M-n)/e,p=e/2}0===l&&0===g?(w=0,R=0):r.CesiumMath.sign(l)===r.CesiumMath.sign(g)?(w=l+g,R=o/w):(R=l-g,w=o/R),0===M&&0===p?(S=0,O=0):r.CesiumMath.sign(M)===r.CesiumMath.sign(p)?(S=M+p,O=a/S):(O=M-p,S=a/O);const x=s.computeRealRoots(1,w,S),y=s.computeRealRoots(1,R,O);if(0!==x.length)return 0!==y.length?x[1]<=y[0]?[x[0],x[1],y[0],y[1]]:y[1]<=x[0]?[y[0],y[1],x[0],x[1]]:x[0]>=y[0]&&x[1]<=y[1]?[y[0],x[0],x[1],y[1]]:y[0]>=x[0]&&y[1]<=x[1]?[x[0],y[0],y[1],x[1]]:x[0]>y[0]&&x[0]<y[1]?[y[0],x[0],y[1],x[1]]:[x[0],y[0],x[1],y[1]]:x;if(0!==y.length)retur