Agriculture-front-end/public/Cesium/Workers/OrientedBoundingBox-f1d7843f.js

2 lines
8.7 KiB
JavaScript
Raw Normal View History

2023-04-16 22:33:44 +08:00
define(["exports","./BoundingSphere-561b54d0","./Cartesian2-47311507","./Cartographic-3309dd0d","./Check-7b2a090c","./when-b60132fc","./EllipsoidTangentPlane-b2b18d75","./Math-119be1a3","./Plane-097b3a8f"],(function(a,t,e,n,r,i,s,o,C){"use strict";function c(a,e){this.center=n.Cartesian3.clone(i.defaultValue(a,n.Cartesian3.ZERO)),this.halfAxes=t.Matrix3.clone(i.defaultValue(e,t.Matrix3.ZERO))}c.packedLength=n.Cartesian3.packedLength+t.Matrix3.packedLength,c.pack=function(a,e,r){return r=i.defaultValue(r,0),n.Cartesian3.pack(a.center,e,r),t.Matrix3.pack(a.halfAxes,e,r+n.Cartesian3.packedLength),e},c.unpack=function(a,e,r){return e=i.defaultValue(e,0),i.defined(r)||(r=new c),n.Cartesian3.unpack(a,e,r.center),t.Matrix3.unpack(a,e+n.Cartesian3.packedLength,r.halfAxes),r};var u=new n.Cartesian3,d=new n.Cartesian3,l=new n.Cartesian3,h=new n.Cartesian3,x=new n.Cartesian3,M=new n.Cartesian3,m=new t.Matrix3,f={unitary:new t.Matrix3,diagonal:new t.Matrix3};c.fromPoints=function(a,e){if(i.defined(e)||(e=new c),!i.defined(a)||0===a.length)return e.halfAxes=t.Matrix3.ZERO,e.center=n.Cartesian3.ZERO,e;var r,s=a.length,o=n.Cartesian3.clone(a[0],u);for(r=1;r<s;r++)n.Cartesian3.add(o,a[r],o);var C=1/s;n.Cartesian3.multiplyByScalar(o,C,o);var p,g=0,w=0,b=0,y=0,O=0,P=0;for(r=0;r<s;r++)g+=(p=n.Cartesian3.subtract(a[r],o,d)).x*p.x,w+=p.x*p.y,b+=p.x*p.z,y+=p.y*p.y,O+=p.y*p.z,P+=p.z*p.z;g*=C,w*=C,b*=C,y*=C,O*=C,P*=C;var N=m;N[0]=g,N[1]=w,N[2]=b,N[3]=w,N[4]=y,N[5]=O,N[6]=b,N[7]=O,N[8]=P;var v=t.Matrix3.computeEigenDecomposition(N,f),A=t.Matrix3.clone(v.unitary,e.halfAxes),T=t.Matrix3.getColumn(A,0,h),R=t.Matrix3.getColumn(A,1,x),I=t.Matrix3.getColumn(A,2,M),E=-Number.MAX_VALUE,L=-Number.MAX_VALUE,z=-Number.MAX_VALUE,S=Number.MAX_VALUE,U=Number.MAX_VALUE,V=Number.MAX_VALUE;for(r=0;r<s;r++)p=a[r],E=Math.max(n.Cartesian3.dot(T,p),E),L=Math.max(n.Cartesian3.dot(R,p),L),z=Math.max(n.Cartesian3.dot(I,p),z),S=Math.min(n.Cartesian3.dot(T,p),S),U=Math.min(n.Cartesian3.dot(R,p),U),V=Math.min(n.Cartesian3.dot(I,p),V);T=n.Cartesian3.multiplyByScalar(T,.5*(S+E),T),R=n.Cartesian3.multiplyByScalar(R,.5*(U+L),R),I=n.Cartesian3.multiplyByScalar(I,.5*(V+z),I);var B=n.Cartesian3.add(T,R,e.center);n.Cartesian3.add(B,I,B);var _=l;return _.x=E-S,_.y=L-U,_.z=z-V,n.Cartesian3.multiplyByScalar(_,.5,_),t.Matrix3.multiplyByScale(e.halfAxes,_,e.halfAxes),e};var p=new n.Cartesian3,g=new n.Cartesian3;function w(a,e,r,s,o,C,u,d,l,h,x){i.defined(x)||(x=new c);var M=x.halfAxes;t.Matrix3.setColumn(M,0,e,M),t.Matrix3.setColumn(M,1,r,M),t.Matrix3.setColumn(M,2,s,M);var m=p;m.x=(o+C)/2,m.y=(u+d)/2,m.z=(l+h)/2;var f=g;f.x=(C-o)/2,f.y=(d-u)/2,f.z=(h-l)/2;var w=x.center;return m=t.Matrix3.multiplyByVector(M,m,m),n.Cartesian3.add(a,m,w),t.Matrix3.multiplyByScale(M,f,M),x}var b=new n.Cartographic,y=new n.Cartesian3,O=new n.Cartographic,P=new n.Cartographic,N=new n.Cartographic,v=new n.Cartographic,A=new n.Cartographic,T=new n.Cartesian3,R=new n.Cartesian3,I=new n.Cartesian3,E=new n.Cartesian3,L=new n.Cartesian3,z=new e.Cartesian2,S=new e.Cartesian2,U=new e.Cartesian2,V=new e.Cartesian2,B=new e.Cartesian2,_=new n.Cartesian3,k=new n.Cartesian3,W=new n.Cartesian3,D=new n.Cartesian3,q=new e.Cartesian2,X=new n.Cartesian3,j=new n.Cartesian3,Z=new n.Cartesian3,G=new C.Plane(n.Cartesian3.UNIT_X,0);c.fromRectangle=function(a,t,r,c,u){var d,l,h,x,M,m,f;if(t=i.defaultValue(t,0),r=i.defaultValue(r,0),c=i.defaultValue(c,e.Ellipsoid.WGS84),a.width<=o.CesiumMath.PI){var p=e.Rectangle.center(a,b),g=c.cartographicToCartesian(p,y),F=new s.EllipsoidTangentPlane(g,c);f=F.plane;var Y=p.longitude,H=a.south<0&&a.north>0?0:p.latitude,J=n.Cartographic.fromRadians(Y,a.north,r,O),K=n.Cartographic.fromRadians(a.west,a.north,r,P),Q=n.Cartographic.fromRadians(a.west,H,r,N),$=n.Cartographic.fromRadians(a.west,a.south,r,v),aa=n.Cartographic.fromRadians(Y,a.south,r,A),ta=c.cartographicToCartesian(J,T),ea=c.cartographicToCartesian(K,R),na=c.cartographicToCartesian(Q,I),ra=c.cartographicToCartesian($,E),ia=c.cartographicToCartesian(aa,L),sa=F.projectPointToNearestOnPlane(ta,z),oa=F.projectPointToNearestOnPlane(ea,S),Ca