Agriculture-front-end/public/Cesium/Workers/OrientedBoundingBox-f1d7843f.js
2023-04-16 22:33:44 +08:00

2 lines
8.7 KiB
JavaScript

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=F.projectPointToNearestOnPlane(na,U),ca=F.projectPointToNearestOnPlane(ra,V),ua=F.projectPointToNearestOnPlane(ia,B);return l=-(d=Math.min(oa.x,Ca.x,ca.x)),x=Math.max(oa.y,sa.y),h=Math.min(ca.y,ua.y),K.height=$.height=t,ea=c.cartographicToCartesian(K,R),ra=c.cartographicToCartesian($,E),M=Math.min(C.Plane.getPointDistance(f,ea),C.Plane.getPointDistance(f,ra)),m=r,w(F.origin,F.xAxis,F.yAxis,F.zAxis,d,l,h,x,M,m,u)}var da=a.south>0,la=a.north<0,ha=da?a.south:la?a.north:0,xa=e.Rectangle.center(a,b).longitude,Ma=n.Cartesian3.fromRadians(xa,ha,r,c,_);Ma.z=0;var ma=Math.abs(Ma.x)<o.CesiumMath.EPSILON10&&Math.abs(Ma.y)<o.CesiumMath.EPSILON10?n.Cartesian3.UNIT_X:n.Cartesian3.normalize(Ma,k),fa=n.Cartesian3.UNIT_Z,pa=n.Cartesian3.cross(ma,fa,W);f=C.Plane.fromPointNormal(Ma,ma,G);var ga=n.Cartesian3.fromRadians(xa+o.CesiumMath.PI_OVER_TWO,ha,r,c,D);d=-(l=n.Cartesian3.dot(C.Plane.projectPointOntoPlane(f,ga,q),pa)),x=n.Cartesian3.fromRadians(0,a.north,la?t:r,c,X).z,h=n.Cartesian3.fromRadians(0,a.south,da?t:r,c,j).z;var wa=n.Cartesian3.fromRadians(a.east,ha,r,c,Z);return w(Ma,pa,fa,ma,d,l,h,x,M=C.Plane.getPointDistance(f,wa),m=0,u)},c.clone=function(a,e){if(i.defined(a))return i.defined(e)?(n.Cartesian3.clone(a.center,e.center),t.Matrix3.clone(a.halfAxes,e.halfAxes),e):new c(a.center,a.halfAxes)},c.intersectPlane=function(a,e){var r=a.center,i=e.normal,s=a.halfAxes,o=i.x,C=i.y,c=i.z,u=Math.abs(o*s[t.Matrix3.COLUMN0ROW0]+C*s[t.Matrix3.COLUMN0ROW1]+c*s[t.Matrix3.COLUMN0ROW2])+Math.abs(o*s[t.Matrix3.COLUMN1ROW0]+C*s[t.Matrix3.COLUMN1ROW1]+c*s[t.Matrix3.COLUMN1ROW2])+Math.abs(o*s[t.Matrix3.COLUMN2ROW0]+C*s[t.Matrix3.COLUMN2ROW1]+c*s[t.Matrix3.COLUMN2ROW2]),d=n.Cartesian3.dot(i,r)+e.distance;return d<=-u?t.Intersect.OUTSIDE:d>=u?t.Intersect.INSIDE:t.Intersect.INTERSECTING};var F=new n.Cartesian3,Y=new n.Cartesian3,H=new n.Cartesian3,J=new n.Cartesian3;c.distanceSquaredTo=function(a,e){var r=n.Cartesian3.subtract(e,a.center,p),i=a.halfAxes,s=t.Matrix3.getColumn(i,0,F),o=t.Matrix3.getColumn(i,1,Y),C=t.Matrix3.getColumn(i,2,H),c=n.Cartesian3.magnitude(s),u=n.Cartesian3.magnitude(o),d=n.Cartesian3.magnitude(C);n.Cartesian3.normalize(s,s),n.Cartesian3.normalize(o,o),n.Cartesian3.normalize(C,C);var l=J;l.x=n.Cartesian3.dot(r,s),l.y=n.Cartesian3.dot(r,o),l.z=n.Cartesian3.dot(r,C);var h,x=0;return l.x<-c?x+=(h=l.x+c)*h:l.x>c&&(x+=(h=l.x-c)*h),l.y<-u?x+=(h=l.y+u)*h:l.y>u&&(x+=(h=l.y-u)*h),l.z<-d?x+=(h=l.z+d)*h:l.z>d&&(x+=(h=l.z-d)*h),x};var K=new n.Cartesian3,Q=new n.Cartesian3;c.computePlaneDistances=function(a,e,r,s){i.defined(s)||(s=new t.Interval);var o=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,c=a.center,u=a.halfAxes,d=t.Matrix3.getColumn(u,0,F),l=t.Matrix3.getColumn(u,1,Y),h=t.Matrix3.getColumn(u,2,H),x=n.Cartesian3.add(d,l,K);n.Cartesian3.add(x,h,x),n.Cartesian3.add(x,c,x);var M=n.Cartesian3.subtract(x,e,Q),m=n.Cartesian3.dot(r,M);return o=Math.min(m,o),C=Math.max(m,C),n.Cartesian3.add(c,d,x),n.Cartesian3.add(x,l,x),n.Cartesian3.subtract(x,h,x),n.Cartesian3.subtract(x,e,M),m=n.Cartesian3.dot(r,M),o=Math.min(m,o),C=Math.max(m,C),n.Cartesian3.add(c,d,x),n.Cartesian3.subtract(x,l,x),n.Cartesian3.add(x,h,x),n.Cartesian3.subtract(x,e,M),m=n.Cartesian3.dot(r,M),o=Math.min(m,o),C=Math.max(m,C),n.Cartesian3.add(c,d,x),n.Cartesian3.subtract(x,l,x),n.Cartesian3.subtract(x,h,x),n.Cartesian3.subtract(x,e,M),m=n.Cartesian3.dot(r,M),o=Math.min(m,o),C=Math.max(m,C),n.Cartesian3.subtract(c,d,x),n.Cartesian3.add(x,l,x),n.Cartesian3.add(x,h,x),n.Cartesian3.subtract(x,e,M),m=n.Cartesian3.dot(r,M),o=Math.min(m,o),C=Math.max(m,C),n.Cartesian3.subtract(c,d,x),n.Cartesian3.add(x,l,x),n.Cartesian3.subtract(x,h,x),n.Cartesian3.subtract(x,e,M),m=n.Cartesian3.dot(r,M),o=Math.min(m,o),C=Math.max(m,C),n.Cartesian3.subtract(c,d,x),n.Cartesian3.subtract(x,l,x),n.Cartesian3.add(x,h,x),n.Cartesian3.subtract(x,e,M),m=n.Cartesian3.dot(r,M),o=Math.min(m,o),C=Math.max(m,C),n.Cartesian3.subtract(c,d,x),n.Cartesian3.subtract(x,l,x),n.Cartesian3.subtract(x,h,x),n.Cartesian3.subtract(x,e,M),m=n.Cartesian3.dot(r,M),o=Math.min(m,o),C=Math.max(m,C),s.start=o,s.stop=C,s};var $=new t.BoundingSphere;c.isOccluded=function(a,e){var n=t.BoundingSphere.fromOrientedBoundingBox(a,$);return!e.isBoundingSphereVisible(n)},c.prototype.intersectPlane=function(a){return c.intersectPlane(this,a)},c.prototype.distanceSquaredTo=function(a){return c.distanceSquaredTo(this,a)},c.prototype.computePlaneDistances=function(a,t,e){return c.computePlaneDistances(this,a,t,e)},c.prototype.isOccluded=function(a){return c.isOccluded(this,a)},c.equals=function(a,e){return a===e||i.defined(a)&&i.defined(e)&&n.Cartesian3.equals(a.center,e.center)&&t.Matrix3.equals(a.halfAxes,e.halfAxes)},c.prototype.clone=function(a){return c.clone(this,a)},c.prototype.equals=function(a){return c.equals(this,a)},a.OrientedBoundingBox=c}));