define(["exports","./Cartesian3-e0307675","./Cartesian2-bd414876","./Check-741c5f3c","./defaultValue-81eec7ed","./GeographicProjection-c931c7fb","./Math-e73894ab","./Matrix4-4c545f70","./Rectangle-cf3e0e3e"],(function(e,n,t,a,r,i,s,c,o){"use strict";var u=Object.freeze({OUTSIDE:-1,INTERSECTING:0,INSIDE:1});function d(e,n){this.start=r.defaultValue(e,0),this.stop=r.defaultValue(n,0)}function C(e,t){this.center=n.Cartesian3.clone(r.defaultValue(e,n.Cartesian3.ZERO)),this.radius=r.defaultValue(t,0)}const l=new n.Cartesian3,f=new n.Cartesian3,y=new n.Cartesian3,m=new n.Cartesian3,x=new n.Cartesian3,g=new n.Cartesian3,h=new n.Cartesian3,z=new n.Cartesian3,w=new n.Cartesian3,p=new n.Cartesian3,S=new n.Cartesian3,q=new n.Cartesian3,b=4/3*s.CesiumMath.PI;C.fromPoints=function(e,t){if(r.defined(t)||(t=new C),!r.defined(e)||0===e.length)return t.center=n.Cartesian3.clone(n.Cartesian3.ZERO,t.center),t.radius=0,t;const a=n.Cartesian3.clone(e[0],h),i=n.Cartesian3.clone(a,l),s=n.Cartesian3.clone(a,f),c=n.Cartesian3.clone(a,y),o=n.Cartesian3.clone(a,m),u=n.Cartesian3.clone(a,x),d=n.Cartesian3.clone(a,g),b=e.length;let E;for(E=1;Eo.x&&n.Cartesian3.clone(a,o),ru.y&&n.Cartesian3.clone(a,u),Cd.z&&n.Cartesian3.clone(a,d)}const R=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(o,i,z)),M=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(u,s,z)),O=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(d,c,z));let P=i,V=o,I=R;M>I&&(I=M,P=s,V=u),O>I&&(I=O,P=c,V=d);const T=w;T.x=.5*(P.x+V.x),T.y=.5*(P.y+V.y),T.z=.5*(P.z+V.z);let D=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(V,T,z)),B=Math.sqrt(D);const Z=p;Z.x=i.x,Z.y=s.y,Z.z=c.z;const N=S;N.x=o.x,N.y=u.y,N.z=d.z;const j=n.Cartesian3.midpoint(Z,N,q);let G=0;for(E=0;EG&&(G=t);const r=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(a,T,z));if(r>D){const e=Math.sqrt(r);B=.5*(B+e),D=B*B;const n=e-B;T.x=(B*T.x+n*a.x)/e,T.y=(B*T.y+n*a.y)/e,T.z=(B*T.z+n*a.z)/e}}return Bd.x&&n.Cartesian3.clone(s,d),rb.y&&n.Cartesian3.clone(s,b),iE.z&&n.Cartesian3.clone(s,E)}const O=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(d,c,z)),P=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(b,o,z)),V=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(E,u,z));let I=c,T=d,D=O;P>D&&(D=P,I=o,T=b),V>D&&(D=V,I=u,T=E);const B=w;B.x=.5*(I.x+T.x),B.y=.5*(I.y+T.y),B.z=.5*(I.z+T.z);let Z=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(T,B,z)),N=Math.sqrt(Z);const j=p;j.x=c.x,j.y=o.y,j.z=u.z;const G=S;G.x=d.x,G.y=b.y,G.z=E.z;const k=n.Cartesian3.midpoint(j,G,q);let U=0;for(M=0;MU&&(U=a);const r=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(s,B,z));if(r>Z){const e=Math.sqrt(r);N=.5*(N+e),Z=N*N;const n=e-N;B.x=(N*B.x+n*s.x)/e,B.y=(N*B.y+n*s.y)/e,B.z=(N*B.z+n*s.z)/e}}return Nu.x&&n.Cartesian3.clone(i,u),rd.y&&n.Cartesian3.clone(i,d),Cb.z&&n.Cartesian3.clone(i,b)}const M=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(u,s,z)),O=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(d,c,z)),P=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(b,o,z));let V=s,I=u,T=M;O>T&&(T=O,V=c,I=d),P>T&&(T=P,V=o,I=b);const D=w;D.x=.5*(V.x+I.x),D.y=.5*(V.y+I.y),D.z=.5*(V.z+I.z);let B=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(I,D,z)),Z=Math.sqrt(B);const N=p;N.x=s.x,N.y=c.y,N.z=o.z;const j=S;j.x=u.x,j.y=d.y,j.z=b.z;const G=n.Cartesian3.midpoint(N,j,q);let k=0;for(R=0;Rk&&(k=a);const r=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(i,D,z));if(r>B){const e=Math.sqrt(r);Z=.5*(Z+e),B=Z*Z;const n=e-Z;D.x=(Z*D.x+n*i.x)/e,D.y=(Z*D.y+n*i.y)/e,D.z=(Z*D.z+n*i.z)/e}}return Z=d+o)return e.clone(a),a;if(o>=d+s)return t.clone(a),a;const l=.5*(s+d+o),f=n.Cartesian3.multiplyByScalar(u,(-s+l)/d,G);return n.Cartesian3.add(f,i,f),n.Cartesian3.clone(f,a.center),a.radius=l,a};const k=new n.Cartesian3;C.expand=function(e,t,a){a=C.clone(e,a);const r=n.Cartesian3.magnitude(n.Cartesian3.subtract(t,a.center,k));return r>a.radius&&(a.radius=r),a},C.intersectPlane=function(e,t){const a=e.center,r=e.radius,i=t.normal,s=n.Cartesian3.dot(i,a)+t.distance;return s<-r?u.OUTSIDE:s