2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
|
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;E<b;E++){n.Cartesian3.clone(e[E],a);const t=a.x,r=a.y,C=a.z;t<i.x&&n.Cartesian3.clone(a,i),t>o.x&&n.Cartesian3.clone(a,o),r<s.y&&n.Cartesian3.clone(a,s),r>u.y&&n.Cartesian3.clone(a,u),C<c.z&&n.Cartesian3.clone(a,c),C>d.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;E<b;E++){n.Cartesian3.clone(e[E],a);const t=n.Cartesian3.magnitude(n.Cartesian3.subtract(a,j,z));t>G&&(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 B<G?(n.Cartesian3.clone(T,t.center),t.radius=B):(n.Cartesian3.clone(j,t.center),t.radius=G),t};const E=new i.GeographicProjection,R=new n.Cartesian3,M=new n.Cartesian3,O=new t.Cartographic,P=new t.Cartographic;C.fromRectangle2D=function(e,n,t){return C.fromRectangleWithHeights2D(e,n,0,0,t)},C.fromRectangleWithHeights2D=function(e,t,a,i,s){if(r.defined(s)||(s=new C),!r.defined(e))return s.center=n.Cartesian3.clone(n.Cartesian3.ZERO,s.center),s.radius=0,s;t=r.defaultValue(t,E),o.Rectangle.southwest(e,O),O.height=a,o.Rectangle.northeast(e,P),P.height=i;const c=t.project(O,R),u=t.project(P,M),d=u.x-c.x,l=u.y-c.y,f=u.z-c.z;s.radius=.5*Math.sqrt(d*d+l*l+f*f);const y=s.center;return y.x=c.x+.5*d,y.y=c.y+.5*l,y.z=c.z+.5*f,s};const V=[];C.fromRectangle3D=function(e,a,i,s){if(a=r.defaultValue(a,t.Ellipsoid.WGS84),i=r.defaultValue(i,0),r.defined(s)||(s=new C),!r.defined(e))return s.center=n.Cartesian3.clone(n.Cartesian3.ZERO,s.center),s.radius=0,s;const c=o.Rectangle.subsample(e,a,i,V);return C.fromPoints(c,s)},C.fromVertices=function(e,t,a,i){if(r.defined(i)||(i=new C),!r.defined(e)||0===e.length)return i.center=n.Cartesian3.clone(n.Cartesian3.ZERO,i.center),i.radius=0,i;t=r.defaultValue(t,n.Cartesian3.ZERO),a=r.defaultValue(a,3);const s=h;s.x=e[0]+t.x,s.y=e[1]+t.y,s.z=e[2]+t.z;const c=n.Cartesian3.clone(s,l),o=n.Cartesian3.clone(s,f),u=n.Cartesian3.clone(s,y),d=n.Cartesian3.clone(s,m),b=n.Cartesian3.clone(s,x),E=n.Cartesian3.clone(s,g),R=e.length;let M;for(M=0;M<R;M+=a){const a=e[M]+t.x,r=e[M+1]+t.y,i=e[M+2]+t.z;s.x=a,s.y=r,s.z=i,a<c.x&&n.Cartesian3.clone(s,c),a>d.x&&n.Cartesian3.clone(s,d),r<o.y&&n.Cartesian3.clone(s,o),r>b.y&&n.Cartesian3.clone(s,b),i<u.z&&n.Cartesian3.clone(s,u),i>E.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
|