define(["exports","./Transforms-3ac41eb6","./Matrix2-fc7e9822","./RuntimeError-c581ca93","./defaultValue-94c3e563","./EllipsoidTangentPlane-53e32153","./ComponentDatatype-4a60b8d6","./Plane-e20fba8c"],(function(a,e,t,n,r,i,s,o){"use strict";function c(a,e){this.center=t.Cartesian3.clone(r.defaultValue(a,t.Cartesian3.ZERO)),this.halfAxes=t.Matrix3.clone(r.defaultValue(e,t.Matrix3.ZERO))}c.packedLength=t.Cartesian3.packedLength+t.Matrix3.packedLength,c.pack=function(a,e,i){return n.Check.typeOf.object("value",a),n.Check.defined("array",e),i=r.defaultValue(i,0),t.Cartesian3.pack(a.center,e,i),t.Matrix3.pack(a.halfAxes,e,i+t.Cartesian3.packedLength),e},c.unpack=function(a,e,i){return n.Check.defined("array",a),e=r.defaultValue(e,0),r.defined(i)||(i=new c),t.Cartesian3.unpack(a,e,i.center),t.Matrix3.unpack(a,e+t.Cartesian3.packedLength,i.halfAxes),i};const C=new t.Cartesian3,d=new t.Cartesian3,u=new t.Cartesian3,l=new t.Cartesian3,h=new t.Cartesian3,f=new t.Cartesian3,m=new t.Matrix3,x={unitary:new t.Matrix3,diagonal:new t.Matrix3};c.fromPoints=function(a,e){if(r.defined(e)||(e=new c),!r.defined(a)||0===a.length)return e.halfAxes=t.Matrix3.ZERO,e.center=t.Cartesian3.ZERO,e;let n;const i=a.length,s=t.Cartesian3.clone(a[0],C);for(n=1;ns.CesiumMath.TWO_PI)throw new n.DeveloperError("Rectangle width must be between 0 and 2*pi");if(a.height<0||a.height>s.CesiumMath.PI)throw new n.DeveloperError("Rectangle height must be between 0 and pi");if(r.defined(C)&&!s.CesiumMath.equalsEpsilon(C.radii.x,C.radii.y,s.CesiumMath.EPSILON15))throw new n.DeveloperError("Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)");let u,l,h,f,m,x,p;if(e=r.defaultValue(e,0),c=r.defaultValue(c,0),C=r.defaultValue(C,t.Ellipsoid.WGS84),a.width<=s.CesiumMath.PI){const n=t.Rectangle.center(a,g),r=C.cartographicToCartesian(n,b),s=new i.EllipsoidTangentPlane(r,C);p=s.plane;const M=n.longitude,z=a.south<0&&a.north>0?0:n.latitude,B=t.Cartographic.fromRadians(M,a.north,c,y),V=t.Cartographic.fromRadians(a.west,a.north,c,O),_=t.Cartographic.fromRadians(a.west,z,c,E),k=t.Cartographic.fromRadians(a.west,a.south,c,N),W=t.Cartographic.fromRadians(M,a.south,c,T),X=C.cartographicToCartesian(B,P);let j=C.cartographicToCartesian(V,A);const Z=C.cartographicToCartesian(_,I);let Y=C.cartographicToCartesian(k,R);const G=C.cartographicToCartesian(W,S),F=s.projectPointToNearestOnPlane(X,U),H=s.projectPointToNearestOnPlane(j,D),J=s.projectPointToNearestOnPlane(Z,L),K=s.projectPointToNearestOnPlane(Y,q),Q=s.projectPointToNearestOnPlane(G,v);return u=Math.min(H.x,J.x,K.x),l=-u,f=Math.max(H.y,F.y),h=Math.min(K.y,Q.y),V.height=k.height=e,j=C.cartographicToCartesian(V,A),Y=C.cartographicToCartesian(k,R),m=Math.min(o.Plane.getPointDistance(p,j),o.Plane.getPointDistance(p,Y)),x=c,w(s.origin,s.xAxis,s.yAxis,s.zAxis,u,l,h,f,m,x,d)}const M=a.south>0,Y=a.north<0,G=M?a.south:Y?a.north:0,F=t.Rectangle.center(a,g).longitude,H=t.Cartesian3.fromRadians(F,G,c,C,z);H.z=0;const J=Math.abs(H.x)=l?e.Intersect.INSIDE:e.Intersect.INTERSECTING};const Y=new t.Cartesian3,G=new t.Cartesian3,F=new t.Cartesian3,H=new t.Cartesian3,J=new t.Cartesian3,K=new t.Cartesian3;c.distanceSquaredTo=function(a,e){if(!r.defined(a))throw new n.DeveloperError("box is required.");if(!r.defined(e))throw new n.DeveloperError("cartesian is required.");const i=t.Cartesian3.subtract(e,a.center,p),o=a.halfAxes;let c=t.Matrix3.getColumn(o,0,Y),C=t.Matrix3.getColumn(o,1,G),d=t.Matrix3.getColumn(o,2,F);const u=t.Cartesian3.magnitude(c),l=t.Cartesian3.magnitude(C),h=t.Cartesian3.magnitude(d);let f=!0,m=!0,x=!0;u>0?t.Cartesian3.divideByScalar(c,u,c):f=!1,l>0?t.Cartesian3.divideByScalar(C,l,C):m=!1,h>0?t.Cartesian3.divideByScalar(d,h,d):x=!1;const M=!f+!m+!x;let w,g,b;if(1===M){let a=c;w=C,g=d,m?x||(a=d,g=c):(a=C,w=c),b=t.Cartesian3.cross(w,g,J),a===c?c=b:a===C?C=b:a===d&&(d=b)}else if(2===M){w=c,m?w=C:x&&(w=d);let a=t.Cartesian3.UNIT_Y;a.equalsEpsilon(w,s.CesiumMath.EPSILON3)&&(a=t.Cartesian3.UNIT_X),g=t.Cartesian3.cross(w,a,H),t.Cartesian3.normalize(g,g),b=t.Cartesian3.cross(w,g,J),t.Cartesian3.normalize(b,b),w===c?(C=g,d=b):w===C?(d=g,c=b):w===d&&(c=g,C=b)}else 3===M&&(c=t.Cartesian3.UNIT_X,C=t.Cartesian3.UNIT_Y,d=t.Cartesian3.UNIT_Z);const y=K;y.x=t.Cartesian3.dot(i,c),y.y=t.Cartesian3.dot(i,C),y.z=t.Cartesian3.dot(i,d);let O,E=0;return y.x<-u?(O=y.x+u,E+=O*O):y.x>u&&(O=y.x-u,E+=O*O),y.y<-l?(O=y.y+l,E+=O*O):y.y>l&&(O=y.y-l,E+=O*O),y.z<-h?(O=y.z+h,E+=O*O):y.z>h&&(O=y.z-h,E+=O*O),E};const Q=new t.Cartesian3,$=new t.Cartesian3;c.computePlaneDistances=function(a,i,s,o){if(!r.defined(a))throw new n.DeveloperError("box is required.");if(!r.defined(i))throw new n.DeveloperError("position is required.");if(!r.defined(s))throw new n.DeveloperError("direction is required.");r.defined(o)||(o=new e.Interval);let c=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY;const d=a.center,u=a.halfAxes,l=t.Matrix3.getColumn(u,0,Y),h=t.Matrix3.getColumn(u,1,G),f=t.Matrix3.getColumn(u,2,F),m=t.Cartesian3.add(l,h,Q);t.Cartesian3.add(m,f,m),t.Cartesian3.add(m,d,m);const x=t.Cartesian3.subtract(m,i,$);let p=t.Cartesian3.dot(s,x);return c=Math.min(p,c),C=Math.max(p,C),t.Cartesian3.add(d,l,m),t.Cartesian3.add(m,h,m),t.Cartesian3.subtract(m,f,m),t.Cartesian3.subtract(m,i,x),p=t.Cartesian3.dot(s,x),c=Math.min(p,c),C=Math.max(p,C),t.Cartesian3.add(d,l,m),t.Cartesian3.subtract(m,h,m),t.Cartesian3.add(m,f,m),t.Cartesian3.subtract(m,i,x),p=t.Cartesian3.dot(s,x),c=Math.min(p,c),C=Math.max(p,C),t.Cartesian3.add(d,l,m),t.Cartesian3.subtract(m,h,m),t.Cartesian3.subtract(m,f,m),t.Cartesian3.subtract(m,i,x),p=t.Cartesian3.dot(s,x),c=Math.min(p,c),C=Math.max(p,C),t.Cartesian3.subtract(d,l,m),t.Cartesian3.add(m,h,m),t.Cartesian3.add(m,f,m),t.Cartesian3.subtract(m,i,x),p=t.Cartesian3.dot(s,x),c=Math.min(p,c),C=Math.max(p,C),t.Cartesian3.subtract(d,l,m),t.Cartesian3.add(m,h,m),t.Cartesian3.subtract(m,f,m),t.Cartesian3.subtract(m,i,x),p=t.Cartesian3.dot(s,x),c=Math.min(p,c),C=Math.max(p,C),t.Cartesian3.subtract(d,l,m),t.Cartesian3.subtract(m,h,m),t.Cartesian3.add(m,f,m),t.Cartesian3.subtract(m,i,x),p=t.Cartesian3.dot(s,x),c=Math.min(p,c),C=Math.max(p,C),t.Cartesian3.subtract(d,l,m),t.Cartesian3.subtract(m,h,m),t.Cartesian3.subtract(m,f,m),t.Cartesian3.subtract(m,i,x),p=t.Cartesian3.dot(s,x),c=Math.min(p,c),C=Math.max(p,C),o.start=c,o.stop=C,o};const aa=new t.Cartesian3,ea=new t.Cartesian3,ta=new t.Cartesian3;c.computeCorners=function(a,e){n.Check.typeOf.object("box",a),r.defined(e)||(e=[new t.Cartesian3,new t.Cartesian3,new t.Cartesian3,new t.Cartesian3,new t.Cartesian3,new t.Cartesian3,new t.Cartesian3,new t.Cartesian3]);const i=a.center,s=a.halfAxes,o=t.Matrix3.getColumn(s,0,aa),c=t.Matrix3.getColumn(s,1,ea),C=t.Matrix3.getColumn(s,2,ta);return t.Cartesian3.clone(i,e[0]),t.Cartesian3.subtract(e[0],o,e[0]),t.Cartesian3.subtract(e[0],c,e[0]),t.Cartesian3.subtract(e[0],C,e[0]),t.Cartesian3.clone(i,e[1]),t.Cartesian3.subtract(e[1],o,e[1]),t.Cartesian3.subtract(e[1],c,e[1]),t.Cartesian3.add(e[1],C,e[1]),t.Cartesian3.clone(i,e[2]),t.Cartesian3.subtract(e[2],o,e[2]),t.Cartesian3.add(e[2],c,e[2]),t.Cartesian3.subtract(e[2],C,e[2]),t.Cartesian3.clone(i,e[3]),t.Cartesian3.subtract(e[3],o,e[3]),t.Cartesian3.add(e[3],c,e[3]),t.Cartesian3.add(e[3],C,e[3]),t.Cartesian3.clone(i,e[4]),t.Cartesian3.add(e[4],o,e[4]),t.Cartesian3.subtract(e[4],c,e[4]),t.Cartesian3.subtract(e[4],C,e[4]),t.Cartesian3.clone(i,e[5]),t.Cartesian3.add(e[5],o,e[5]),t.Cartesian3.subtract(e[5],c,e[5]),t.Cartesian3.add(e[5],C,e[5]),t.Cartesian3.clone(i,e[6]),t.Cartesian3.add(e[6],o,e[6]),t.Cartesian3.add(e[6],c,e[6]),t.Cartesian3.subtract(e[6],C,e[6]),t.Cartesian3.clone(i,e[7]),t.Cartesian3.add(e[7],o,e[7]),t.Cartesian3.add(e[7],c,e[7]),t.Cartesian3.add(e[7],C,e[7]),e};const na=new t.Matrix3;c.computeTransformation=function(a,e){n.Check.typeOf.object("box",a),r.defined(e)||(e=new t.Matrix4);const i=a.center,s=t.Matrix3.multiplyByUniformScale(a.halfAxes,2,na);return t.Matrix4.fromRotationTranslation(s,i,e)};const ra=new e.BoundingSphere;c.isOccluded=function(a,t){if(!r.defined(a))throw new n.DeveloperError("box is required.");if(!r.defined(t))throw new n.DeveloperError("occluder is required.");const i=e.BoundingSphere.fromOrientedBoundingBox(a,ra);return!t.isBoundingSphereVisible(i)},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,e,t){return c.computePlaneDistances(this,a,e,t)},c.prototype.computeCorners=function(a){return c.computeCorners(this,a)},c.prototype.computeTransformation=function(a){return c.computeTransformation(this,a)},c.prototype.isOccluded=function(a){return c.isOccluded(this,a)},c.equals=function(a,e){return a===e||r.defined(a)&&r.defined(e)&&t.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}));