2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
|
define(["exports","./Cartesian3-e0307675","./Cartesian2-bd414876","./defaultValue-81eec7ed","./Check-741c5f3c","./BoundingSphere-9a3b5656","./Math-e73894ab","./Matrix4-4c545f70"],(function(t,e,n,a,i,r,s,o){"use strict";const c={};function u(t,e,n){const a=t+e;return s.CesiumMath.sign(t)!==s.CesiumMath.sign(e)&&Math.abs(a/Math.max(Math.abs(t),Math.abs(e)))<n?0:a}c.computeDiscriminant=function(t,e,n){return e*e-4*t*n},c.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<s.CesiumMath.EPSILON14)return[0,0];if(e>i&&i/e<s.CesiumMath.EPSILON14)return[];if(a=-n/t,a<0)return[];const r=Math.sqrt(a);return[-r,r]}if(0===n)return a=-e/t,a<0?[a,0]:[0,a];const i=u(e*e,-(4*t*n),s.CesiumMath.EPSILON14);if(i<0)return[];const r=-.5*u(e,s.CesiumMath.sign(e)*Math.sqrt(i),s.CesiumMath.EPSILON14);return e>0?[r/t,n/r]:[n/r,r/t]};const l={};function C(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,h=i*s-l,M=i*o-r*s,d=r*o-C,f=4*h*d-M*M;let m,g;if(f<0){let t,e,n;l*u>=c*C?(t=i,e=h,n=-2*r*h+i*M):(t=o,e=d,n=-o*M+2*s*d);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 m=e<=0?w+R:-n/(w*w+R*R+e),l*u>=c*C?[(m-r)/i]:[-o/(m+s)]}const p=h,w=-2*r*h+i*M,R=d,S=-o*M+2*s*d,O=Math.sqrt(f),x=Math.sqrt(3)/2;let y=Math.abs(Math.atan2(i*O,-w)/3);m=2*Math.sqrt(-p);let P=Math.cos(y);g=m*P;let b=m*(-P/2-x*Math.sin(y));const N=g+b>2*r?g-r:b-r,q=i,L=N/q;y=Math.abs(Math.atan2(o*O,-S)/3),m=2*Math.sqrt(-R),P=Math.cos(y),g=m*P,b=m*(-P/2-x*Math.sin(y));const I=-o,E=g+b<2*s?g+s:b+s,z=I/E,v=-N*E-q*I,T=(s*v-r*(N*I))/(-r*v+s*(q*E));return L<=T?L<=z?T<=z?[L,T,z]:[L,z,T]:[z,L,T]:L<=z?[T,L,z]:T<=z?[T,z,L]:[z,T,L]}l.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)},l.computeRealRoots=function(t,e,n,a){let i,r;if(0===t)return c.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=c.computeRealRoots(t,0,n),0===i.Length?[0]:[i[0],0,i[1]]):C(t,0,n,a)}return 0===n?0===a?(r=-e/t,r<0?[r,0,0]:[0,0,r]):C(t,e,0,a):0===a?(i=c.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]]):C(t,e,n,a)};const h={};function M(t,e,n,a){const i=t*t,r=e-3*i/8,o=n-e*t/2+i*t/8,u=a-n*t/4+e*i/16-3*i*i/256,C=l.computeRealRoots(1,2*r,r*r-4*u,-o*o);if(C.length>0){const e=-t/4,n=C[C.length-1];if(Math.abs(n)<s.CesiumMath.EPSILON14){const t=c.computeRealRoots(1,r,u);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=(r+n-o/t)/2,i=(r+n+o/t)/2,s=c.computeRealRoots(1,t,a),u=c.computeRealRoots(1,-t,i);return 0!==s.length?(s[0]+=e,s[1]+=e,0!==u.length?(u[0]+=e,u[1]+=e,s[1]<=u[0]?[s[0],s[1],u[0],u[1]]:u[1]<=s[0]?[u[0],u[1],s[0],s[1]]:s[0]>=u[0]&&s[1]<=u[1]?[u[0],s[0],s[1],u[1]]:u[0]>=s[0]&&u[1]<=s[1]?[s[0],u[0],u[1],s[1]]:s[0]>u[0]&&s[0]<u[1]?[u[0],s[0],u[1],s[1]]:[s[0],u[0],s[1],u[1]]):s):0!==u.length?(u[0]+=e,u[1]+=e,u):[]}}return[]}function d(t,e,n,a){const i=t*t,r=-2*e,o=n*t+e*e-4*a,u=i*a-n*e*t+n*n,C=l.computeRealRoots(1,r,o,u);if(C.length>0){const r=C[0],o=e-r,u=o*o,l=t/2,h=o/2,M=u-4*a,d=u+4*Math.abs(a),f=i-4*r,m=i+4*Math.abs(r);let g,p,w,R,S,O;if(r<0||M*m<f*d){const e=Math.sqrt(f);g=e/2,p=0===e?0:(t*h-n)/e}else{const e=Math.sqrt(M);g=0===e?0:(t*h-n)/e,p=e/2}0===l&&0===g?(w=0,R=0):s.CesiumMath.sign(l)===s.CesiumMath.sign(g)?(w=l+g,R=r/w):(R=l-g,w=r/R),0===h&&0===p?(S=0,O=0):s.CesiumMath.sign(h)===s.CesiumMath.sign(p)?(S=h+p,O=a/S):(O=h-p,S=a/O);const x=c.computeRealRoots(1,w,S),y=c.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
|