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

2 lines
11 KiB
JavaScript

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.cartographicToCartesian(j,B),H=o.projectPointToNearestOnPlane(Z,z),J=o.projectPointToNearestOnPlane(v,V),K=o.projectPointToNearestOnPlane(Y,_),Q=o.projectPointToNearestOnPlane(G,k),$=o.projectPointToNearestOnPlane(F,W);return d=Math.min(J.x,K.x,Q.x),h=-d,m=Math.max(J.y,H.y),x=Math.min(Q.y,$.y),X.height=D.height=t,v=c.cartographicToCartesian(X,E),G=c.cartographicToCartesian(D,L),M=Math.min(C.Plane.getPointDistance(p,v),C.Plane.getPointDistance(p,G)),f=r,y(o.origin,o.xAxis,o.yAxis,o.zAxis,d,h,x,m,M,f,l)}const w=a.south>0,g=a.north<0,b=w?a.south:g?a.north:0,H=u.Rectangle.center(a,N).longitude,J=n.Cartesian3.fromRadians(H,b,r,c,X);J.z=0;const K=Math.abs(J.x)<o.CesiumMath.EPSILON10&&Math.abs(J.y)<o.CesiumMath.EPSILON10?n.Cartesian3.UNIT_X:n.Cartesian3.normalize(J,q),Q=n.Cartesian3.UNIT_Z,$=n.Cartesian3.cross(K,Q,D);p=C.Plane.fromPointNormal(J,K,F);const aa=n.Cartesian3.fromRadians(H+o.CesiumMath.PI_OVER_TWO,b,r,c,j);h=n.Cartesian3.dot(C.Plane.projectPointOntoPlane(p,aa,Z),$),d=-h,m=n.Cartesian3.fromRadians(0,a.north,g?t:r,c,v).z,x=n.Cartesian3.fromRadians(0,a.south,w?t:r,c,Y).z;const ta=n.Cartesian3.fromRadians(a.east,b,r,c,G);return M=C.Plane.getPointDistance(p,ta),f=0,y(J,$,Q,K,d,h,x,m,M,f,l)},l.fromTransformation=function(a,t){return i.defined(t)||(t=new l),t.center=c.Matrix4.getTranslation(a,t.center),t.halfAxes=c.Matrix4.getMatrix3(a,t.halfAxes),t.halfAxes=c.Matrix3.multiplyByScalar(t.halfAxes,.5,t.halfAxes),t},l.clone=function(a,t){if(i.defined(a))return i.defined(t)?(n.Cartesian3.clone(a.center,t.center),c.Matrix3.clone(a.halfAxes,t.halfAxes),t):new l(a.center,a.halfAxes)},l.intersectPlane=function(a,e){const r=a.center,i=e.normal,s=a.halfAxes,o=i.x,C=i.y,u=i.z,l=Math.abs(o*s[c.Matrix3.COLUMN0ROW0]+C*s[c.Matrix3.COLUMN0ROW1]+u*s[c.Matrix3.COLUMN0ROW2])+Math.abs(o*s[c.Matrix3.COLUMN1ROW0]+C*s[c.Matrix3.COLUMN1ROW1]+u*s[c.Matrix3.COLUMN1ROW2])+Math.abs(o*s[c.Matrix3.COLUMN2ROW0]+C*s[c.Matrix3.COLUMN2ROW1]+u*s[c.Matrix3.COLUMN2ROW2]),d=n.Cartesian3.dot(i,r)+e.distance;return d<=-l?t.Intersect.OUTSIDE:d>=l?t.Intersect.INSIDE:t.Intersect.INTERSECTING};const H=new n.Cartesian3,J=new n.Cartesian3,K=new n.Cartesian3,Q=new n.Cartesian3,$=new n.Cartesian3,aa=new n.Cartesian3;l.distanceSquaredTo=function(a,t){const e=n.Cartesian3.subtract(t,a.center,g),r=a.halfAxes;let i=c.Matrix3.getColumn(r,0,H),s=c.Matrix3.getColumn(r,1,J),C=c.Matrix3.getColumn(r,2,K);const u=n.Cartesian3.magnitude(i),l=n.Cartesian3.magnitude(s),d=n.Cartesian3.magnitude(C);let h=!0,x=!0,m=!0;u>0?n.Cartesian3.divideByScalar(i,u,i):h=!1,l>0?n.Cartesian3.divideByScalar(s,l,s):x=!1,d>0?n.Cartesian3.divideByScalar(C,d,C):m=!1;const M=!h+!x+!m;let f,p,w;if(1===M){let a=i;f=s,p=C,x?m||(a=C,p=i):(a=s,f=i),w=n.Cartesian3.cross(f,p,$),a===i?i=w:a===s?s=w:a===C&&(C=w)}else if(2===M){f=i,x?f=s:m&&(f=C);let a=n.Cartesian3.UNIT_Y;a.equalsEpsilon(f,o.CesiumMath.EPSILON3)&&(a=n.Cartesian3.UNIT_X),p=n.Cartesian3.cross(f,a,Q),n.Cartesian3.normalize(p,p),w=n.Cartesian3.cross(f,p,$),n.Cartesian3.normalize(w,w),f===i?(s=p,C=w):f===s?(C=p,i=w):f===C&&(i=p,s=w)}else 3===M&&(i=n.Cartesian3.UNIT_X,s=n.Cartesian3.UNIT_Y,C=n.Cartesian3.UNIT_Z);const b=aa;b.x=n.Cartesian3.dot(e,i),b.y=n.Cartesian3.dot(e,s),b.z=n.Cartesian3.dot(e,C);let y,N=0;return b.x<-u?(y=b.x+u,N+=y*y):b.x>u&&(y=b.x-u,N+=y*y),b.y<-l?(y=b.y+l,N+=y*y):b.y>l&&(y=b.y-l,N+=y*y),b.z<-d?(y=b.z+d,N+=y*y):b.z>d&&(y=b.z-d,N+=y*y),N};const ta=new n.Cartesian3,ea=new n.Cartesian3;l.computePlaneDistances=function(a,e,r,s){i.defined(s)||(s=new t.Interval);let o=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY;const u=a.center,l=a.halfAxes,d=c.Matrix3.getColumn(l,0,H),h=c.Matrix3.getColumn(l,1,J),x=c.Matrix3.getColumn(l,2,K),m=n.Cartesian3.add(d,h,ta);n.Cartesian3.add(m,x,m),n.Cartesian3.add(m,u,m);const M=n.Cartesian3.subtract(m,e,ea);let f=n.Cartesian3.dot(r,M);return o=Math.min(f,o),C=Math.max(f,C),n.Cartesian3.add(u,d,m),n.Cartesian3.add(m,h,m),n.Cartesian3.subtract(m,x,m),n.Cartesian3.subtract(m,e,M),f=n.Cartesian3.dot(r,M),o=Math.min(f,o),C=Math.max(f,C),n.Cartesian3.add(u,d,m),n.Cartesian3.subtract(m,h,m),n.Cartesian3.add(m,x,m),n.Cartesian3.subtract(m,e,M),f=n.Cartesian3.dot(r,M),o=Math.min(f,o),C=Math.max(f,C),n.Cartesian3.add(u,d,m),n.Cartesian3.subtract(m,h,m),n.Cartesian3.subtract(m,x,m),n.Cartesian3.subtract(m,e,M),f=n.Cartesian3.dot(r,M),o=Math.min(f,o),C=Math.max(f,C),n.Cartesian3.subtract(u,d,m),n.Cartesian3.add(m,h,m),n.Cartesian3.add(m,x,m),n.Cartesian3.subtract(m,e,M),f=n.Cartesian3.dot(r,M),o=Math.min(f,o),C=Math.max(f,C),n.Cartesian3.subtract(u,d,m),n.Cartesian3.add(m,h,m),n.Cartesian3.subtract(m,x,m),n.Cartesian3.subtract(m,e,M),f=n.Cartesian3.dot(r,M),o=Math.min(f,o),C=Math.max(f,C),n.Cartesian3.subtract(u,d,m),n.Cartesian3.subtract(m,h,m),n.Cartesian3.add(m,x,m),n.Cartesian3.subtract(m,e,M),f=n.Cartesian3.dot(r,M),o=Math.min(f,o),C=Math.max(f,C),n.Cartesian3.subtract(u,d,m),n.Cartesian3.subtract(m,h,m),n.Cartesian3.subtract(m,x,m),n.Cartesian3.subtract(m,e,M),f=n.Cartesian3.dot(r,M),o=Math.min(f,o),C=Math.max(f,C),s.start=o,s.stop=C,s};const na=new n.Cartesian3,ra=new n.Cartesian3,ia=new n.Cartesian3;l.computeCorners=function(a,t){i.defined(t)||(t=[new n.Cartesian3,new n.Cartesian3,new n.Cartesian3,new n.Cartesian3,new n.Cartesian3,new n.Cartesian3,new n.Cartesian3,new n.Cartesian3]);const e=a.center,r=a.halfAxes,s=c.Matrix3.getColumn(r,0,na),o=c.Matrix3.getColumn(r,1,ra),C=c.Matrix3.getColumn(r,2,ia);return n.Cartesian3.clone(e,t[0]),n.Cartesian3.subtract(t[0],s,t[0]),n.Cartesian3.subtract(t[0],o,t[0]),n.Cartesian3.subtract(t[0],C,t[0]),n.Cartesian3.clone(e,t[1]),n.Cartesian3.subtract(t[1],s,t[1]),n.Cartesian3.subtract(t[1],o,t[1]),n.Cartesian3.add(t[1],C,t[1]),n.Cartesian3.clone(e,t[2]),n.Cartesian3.subtract(t[2],s,t[2]),n.Cartesian3.add(t[2],o,t[2]),n.Cartesian3.subtract(t[2],C,t[2]),n.Cartesian3.clone(e,t[3]),n.Cartesian3.subtract(t[3],s,t[3]),n.Cartesian3.add(t[3],o,t[3]),n.Cartesian3.add(t[3],C,t[3]),n.Cartesian3.clone(e,t[4]),n.Cartesian3.add(t[4],s,t[4]),n.Cartesian3.subtract(t[4],o,t[4]),n.Cartesian3.subtract(t[4],C,t[4]),n.Cartesian3.clone(e,t[5]),n.Cartesian3.add(t[5],s,t[5]),n.Cartesian3.subtract(t[5],o,t[5]),n.Cartesian3.add(t[5],C,t[5]),n.Cartesian3.clone(e,t[6]),n.Cartesian3.add(t[6],s,t[6]),n.Cartesian3.add(t[6],o,t[6]),n.Cartesian3.subtract(t[6],C,t[6]),n.Cartesian3.clone(e,t[7]),n.Cartesian3.add(t[7],s,t[7]),n.Cartesian3.add(t[7],o,t[7]),n.Cartesian3.add(t[7],C,t[7]),t};const sa=new c.Matrix3;l.computeTransformation=function(a,t){i.defined(t)||(t=new c.Matrix4);const e=a.center,n=c.Matrix3.multiplyByUniformScale(a.halfAxes,2,sa);return c.Matrix4.fromRotationTranslation(n,e,t)};const oa=new t.BoundingSphere;l.isOccluded=function(a,e){const n=t.BoundingSphere.fromOrientedBoundingBox(a,oa);return!e.isBoundingSphereVisible(n)},l.prototype.intersectPlane=function(a){return l.intersectPlane(this,a)},l.prototype.distanceSquaredTo=function(a){return l.distanceSquaredTo(this,a)},l.prototype.computePlaneDistances=function(a,t,e){return l.computePlaneDistances(this,a,t,e)},l.prototype.computeCorners=function(a){return l.computeCorners(this,a)},l.prototype.computeTransformation=function(a){return l.computeTransformation(this,a)},l.prototype.isOccluded=function(a){return l.isOccluded(this,a)},l.equals=function(a,t){return a===t||i.defined(a)&&i.defined(t)&&n.Cartesian3.equals(a.center,t.center)&&c.Matrix3.equals(a.halfAxes,t.halfAxes)},l.prototype.clone=function(a){return l.clone(this,a)},l.prototype.equals=function(a){return l.equals(this,a)},a.OrientedBoundingBox=l}));