qa-regulatory-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/OrientedBoundingBox-c5d2adb...

2 lines
11 KiB
JavaScript
Raw Permalink Normal View History

2023-11-07 10:04:37 +08:00
define(["exports","./BoundingSphere-9a3b5656","./Cartesian2-bd414876","./Cartesian3-e0307675","./Check-741c5f3c","./defaultValue-81eec7ed","./EllipsoidTangentPlane-4d138901","./Math-e73894ab","./Matrix4-4c545f70","./Plane-bc8b6777","./Rectangle-cf3e0e3e"],(function(a,t,e,n,r,i,s,o,c,C,u){"use strict";function l(a,t){this.center=n.Cartesian3.clone(i.defaultValue(a,n.Cartesian3.ZERO)),this.halfAxes=c.Matrix3.clone(i.defaultValue(t,c.Matrix3.ZERO))}l.packedLength=n.Cartesian3.packedLength+c.Matrix3.packedLength,l.pack=function(a,t,e){return e=i.defaultValue(e,0),n.Cartesian3.pack(a.center,t,e),c.Matrix3.pack(a.halfAxes,t,e+n.Cartesian3.packedLength),t},l.unpack=function(a,t,e){return t=i.defaultValue(t,0),i.defined(e)||(e=new l),n.Cartesian3.unpack(a,t,e.center),c.Matrix3.unpack(a,t+n.Cartesian3.packedLength,e.halfAxes),e};const d=new n.Cartesian3,h=new n.Cartesian3,x=new n.Cartesian3,m=new n.Cartesian3,M=new n.Cartesian3,f=new n.Cartesian3,p=new c.Matrix3,w={unitary:new c.Matrix3,diagonal:new c.Matrix3};l.fromPoints=function(a,t){if(i.defined(t)||(t=new l),!i.defined(a)||0===a.length)return t.halfAxes=c.Matrix3.ZERO,t.center=n.Cartesian3.ZERO,t;let e;const r=a.length,s=n.Cartesian3.clone(a[0],d);for(e=1;e<r;e++)n.Cartesian3.add(s,a[e],s);const o=1/r;n.Cartesian3.multiplyByScalar(s,o,s);let C,u=0,g=0,b=0,y=0,N=0,O=0;for(e=0;e<r;e++)C=n.Cartesian3.subtract(a[e],s,h),u+=C.x*C.x,g+=C.x*C.y,b+=C.x*C.z,y+=C.y*C.y,N+=C.y*C.z,O+=C.z*C.z;u*=o,g*=o,b*=o,y*=o,N*=o,O*=o;const T=p;T[0]=u,T[1]=g,T[2]=b,T[3]=g,T[4]=y,T[5]=N,T[6]=b,T[7]=N,T[8]=O;const A=c.Matrix3.computeEigenDecomposition(T,w),P=c.Matrix3.clone(A.unitary,t.halfAxes);let I=c.Matrix3.getColumn(P,0,m),R=c.Matrix3.getColumn(P,1,M),S=c.Matrix3.getColumn(P,2,f),E=-Number.MAX_VALUE,U=-Number.MAX_VALUE,L=-Number.MAX_VALUE,B=Number.MAX_VALUE,z=Number.MAX_VALUE,V=Number.MAX_VALUE;for(e=0;e<r;e++)C=a[e],E=Math.max(n.Cartesian3.dot(I,C),E),U=Math.max(n.Cartesian3.dot(R,C),U),L=Math.max(n.Cartesian3.dot(S,C),L),B=Math.min(n.Cartesian3.dot(I,C),B),z=Math.min(n.Cartesian3.dot(R,C),z),V=Math.min(n.Cartesian3.dot(S,C),V);I=n.Cartesian3.multiplyByScalar(I,.5*(B+E),I),R=n.Cartesian3.multiplyByScalar(R,.5*(z+U),R),S=n.Cartesian3.multiplyByScalar(S,.5*(V+L),S);const _=n.Cartesian3.add(I,R,t.center);n.Cartesian3.add(_,S,_);const k=x;return k.x=E-B,k.y=U-z,k.z=L-V,n.Cartesian3.multiplyByScalar(k,.5,k),c.Matrix3.multiplyByScale(t.halfAxes,k,t.halfAxes),t};const g=new n.Cartesian3,b=new n.Cartesian3;function y(a,t,e,r,s,o,C,u,d,h,x){i.defined(x)||(x=new l);const m=x.halfAxes;c.Matrix3.setColumn(m,0,t,m),c.Matrix3.setColumn(m,1,e,m),c.Matrix3.setColumn(m,2,r,m);let M=g;M.x=(s+o)/2,M.y=(C+u)/2,M.z=(d+h)/2;const f=b;f.x=(o-s)/2,f.y=(u-C)/2,f.z=(h-d)/2;const p=x.center;return M=c.Matrix3.multiplyByVector(m,M,M),n.Cartesian3.add(a,M,p),c.Matrix3.multiplyByScale(m,f,m),x}const N=new e.Cartographic,O=new n.Cartesian3,T=new e.Cartographic,A=new e.Cartographic,P=new e.Cartographic,I=new e.Cartographic,R=new e.Cartographic,S=new n.Cartesian3,E=new n.Cartesian3,U=new n.Cartesian3,L=new n.Cartesian3,B=new n.Cartesian3,z=new e.Cartesian2,V=new e.Cartesian2,_=new e.Cartesian2,k=new e.Cartesian2,W=new e.Cartesian2,X=new n.Cartesian3,q=new n.Cartesian3,D=new n.Cartesian3,j=new n.Cartesian3,Z=new e.Cartesian2,v=new n.Cartesian3,Y=new n.Cartesian3,G=new n.Cartesian3,F=new C.Plane(n.Cartesian3.UNIT_X,0);l.fromRectangle=function(a,t,r,c,l){let d,h,x,m,M,f,p;if(t=i.defaultValue(t,0),r=i.defaultValue(r,0),c=i.defaultValue(c,e.Ellipsoid.WGS84),a.width<=o.CesiumMath.PI){const n=u.Rectangle.center(a,N),i=c.cartographicToCartesian(n,O),o=new s.EllipsoidTangentPlane(i,c);p=o.plane;const w=n.longitude,g=a.south<0&&a.north>0?0:n.latitude,b=e.Cartographic.fromRadians(w,a.north,r,T),X=e.Cartographic.fromRadians(a.west,a.north,r,A),q=e.Cartographic.fromRadians(a.west,g,r,P),D=e.Cartographic.fromRadians(a.west,a.south,r,I),j=e.Cartographic.fromRadians(w,a.south,r,R),Z=c.cartographicToCartesian(b,S);let v=c.cartographicToCartesian(X,E);const Y=c.cartographicToCartesian(q,U);let G=c.cartographicToCartesian(D,L);const F=c.cartogra