learning_cesium/js/XbsjCesium/Workers/OrientedBoundingBox-d1fd9cf...

2 lines
8.6 KiB
JavaScript
Raw Permalink Normal View History

2024-03-19 18:06:25 +08:00
define(["exports","./Transforms-251ff661","./Cartesian2-697a9954","./Check-f3fec9b0","./when-54335d57","./EllipsoidTangentPlane-ae33ec6a","./Math-737a2579","./Plane-d4cb7bb3"],function(a,O,P,t,N,w,y,b){"use strict";function A(a,t){this.center=P.Cartesian3.clone(N.defaultValue(a,P.Cartesian3.ZERO)),this.halfAxes=O.Matrix3.clone(N.defaultValue(t,O.Matrix3.ZERO))}A.packedLength=P.Cartesian3.packedLength+O.Matrix3.packedLength,A.pack=function(a,t,e){return e=N.defaultValue(e,0),P.Cartesian3.pack(a.center,t,e),O.Matrix3.pack(a.halfAxes,t,e+P.Cartesian3.packedLength),t},A.unpack=function(a,t,e){return t=N.defaultValue(t,0),N.defined(e)||(e=new A),P.Cartesian3.unpack(a,t,e.center),O.Matrix3.unpack(a,t+P.Cartesian3.packedLength,e.halfAxes),e};var T=new P.Cartesian3,R=new P.Cartesian3,I=new P.Cartesian3,E=new P.Cartesian3,L=new P.Cartesian3,z=new P.Cartesian3,S=new O.Matrix3,U={unitary:new O.Matrix3,diagonal:new O.Matrix3};A.fromPoints=function(a,t){if(N.defined(t)||(t=new A),!N.defined(a)||0===a.length)return t.halfAxes=O.Matrix3.ZERO,t.center=P.Cartesian3.ZERO,t;for(var e=a.length,n=P.Cartesian3.clone(a[0],T),r=1;r<e;r++)P.Cartesian3.add(n,a[r],n);var i=1/e;P.Cartesian3.multiplyByScalar(n,i,n);var s,o=0,C=0,c=0,u=0,l=0,d=0;for(r=0;r<e;r++)o+=(s=P.Cartesian3.subtract(a[r],n,R)).x*s.x,C+=s.x*s.y,c+=s.x*s.z,u+=s.y*s.y,l+=s.y*s.z,d+=s.z*s.z;C*=i,c*=i,u*=i,l*=i,d*=i;var h=S;h[0]=o*=i,h[1]=C,h[2]=c,h[3]=C,h[4]=u,h[5]=l,h[6]=c,h[7]=l,h[8]=d;var h=O.Matrix3.computeEigenDecomposition(h,U),h=O.Matrix3.clone(h.unitary,t.halfAxes),x=O.Matrix3.getColumn(h,0,E),M=O.Matrix3.getColumn(h,1,L),m=O.Matrix3.getColumn(h,2,z),f=-Number.MAX_VALUE,p=-Number.MAX_VALUE,g=-Number.MAX_VALUE,w=Number.MAX_VALUE,y=Number.MAX_VALUE,b=Number.MAX_VALUE;for(r=0;r<e;r++)s=a[r],f=Math.max(P.Cartesian3.dot(x,s),f),p=Math.max(P.Cartesian3.dot(M,s),p),g=Math.max(P.Cartesian3.dot(m,s),g),w=Math.min(P.Cartesian3.dot(x,s),w),y=Math.min(P.Cartesian3.dot(M,s),y),b=Math.min(P.Cartesian3.dot(m,s),b);x=P.Cartesian3.multiplyByScalar(x,.5*(w+f),x),M=P.Cartesian3.multiplyByScalar(M,.5*(y+p),M),m=P.Cartesian3.multiplyByScalar(m,.5*(b+g),m),h=P.Cartesian3.add(x,M,t.center);P.Cartesian3.add(h,m,h);h=I;return h.x=f-w,h.y=p-y,h.z=g-b,P.Cartesian3.multiplyByScalar(h,.5,h),O.Matrix3.multiplyByScale(t.halfAxes,h,t.halfAxes),t};var d=new P.Cartesian3,h=new P.Cartesian3;function v(a,t,e,n,r,i,s,o,C,c,u){var l=(u=!N.defined(u)?new A:u).halfAxes;O.Matrix3.setColumn(l,0,t,l),O.Matrix3.setColumn(l,1,e,l),O.Matrix3.setColumn(l,2,n,l),(e=d).x=(r+i)/2,e.y=(s+o)/2,e.z=(C+c)/2;n=h;n.x=(i-r)/2,n.y=(o-s)/2,n.z=(c-C)/2;C=u.center,e=O.Matrix3.multiplyByVector(l,e,e);return P.Cartesian3.add(a,e,C),O.Matrix3.multiplyByScale(l,n,l),u}var V=new P.Cartographic,B=new P.Cartesian3,_=new P.Cartographic,k=new P.Cartographic,W=new P.Cartographic,D=new P.Cartographic,q=new P.Cartographic,X=new P.Cartesian3,j=new P.Cartesian3,Z=new P.Cartesian3,G=new P.Cartesian3,F=new P.Cartesian3,Y=new P.Cartesian2,H=new P.Cartesian2,J=new P.Cartesian2,K=new P.Cartesian2,Q=new P.Cartesian2,$=new P.Cartesian3,aa=new P.Cartesian3,ta=new P.Cartesian3,ea=new P.Cartesian3,na=new P.Cartesian2,ra=new P.Cartesian3,ia=new P.Cartesian3,sa=new P.Cartesian3,oa=new b.Plane(P.Cartesian3.UNIT_X,0);A.fromRectangle=function(a,t,e,n,r){if(t=N.defaultValue(t,0),e=N.defaultValue(e,0),n=N.defaultValue(n,P.Ellipsoid.WGS84),a.width<=y.CesiumMath.PI){var i=P.Rectangle.center(a,V),s=n.cartographicToCartesian(i,B),o=new w.EllipsoidTangentPlane(s,n),C=o.plane,c=i.longitude,u=a.south<0&&0<a.north?0:i.latitude,l=P.Cartographic.fromRadians(c,a.north,e,_),d=P.Cartographic.fromRadians(a.west,a.north,e,k),h=P.Cartographic.fromRadians(a.west,u,e,W),x=P.Cartographic.fromRadians(a.west,a.south,e,D),M=P.Cartographic.fromRadians(c,a.south,e,q),m=n.cartographicToCartesian(l,X),f=n.cartographicToCartesian(d,j),p=n.cartographicToCartesian(h,Z),g=n.cartographicToCartesian(x,G),s=n.cartographicToCartesian(M,F),i=o.projectPointToNearestOnPlane(m,Y),u=o.projectPointToNearestOnPlane(f,H),c=o.projectPointToNearestOnPlane(p,J),l=o.projectPointToNearestOnPlane(g,K),h=o.proj