define(["exports","./when-77f4e3be","./Check-d71f548f","./Math-b81aa1f1"],function(e,A,i,b){"use strict";function V(e,t,n){this.x=A.defaultValue(e,0),this.y=A.defaultValue(t,0),this.z=A.defaultValue(n,0)}V.fromSpherical=function(e,t){A.defined(t)||(t=new V);var n=e.clock,a=e.cone,r=A.defaultValue(e.magnitude,1),i=r*Math.sin(a);return t.x=i*Math.cos(n),t.y=i*Math.sin(n),t.z=r*Math.cos(a),t},V.fromElements=function(e,t,n,a){return A.defined(a)?(a.x=e,a.y=t,a.z=n,a):new V(e,t,n)},V.fromCartesian4=V.clone=function(e,t){if(A.defined(e))return A.defined(t)?(t.x=e.x,t.y=e.y,t.z=e.z,t):new V(e.x,e.y,e.z)},V.packedLength=3,V.pack=function(e,t,n){return n=A.defaultValue(n,0),t[n++]=e.x,t[n++]=e.y,t[n]=e.z,t},V.unpack=function(e,t,n){return t=A.defaultValue(t,0),A.defined(n)||(n=new V),n.x=e[t++],n.y=e[t++],n.z=e[t],n},V.packArray=function(e,t){var n=e.length,a=3*n;if(A.defined(t)){if(!Array.isArray(t)&&t.length!==a)throw new i.DeveloperError("If result is a typed array, it must have exactly array.length * 3 elements");t.length!==a&&(t.length=a)}else t=new Array(a);for(var r=0;r<n;++r)V.pack(e[r],t,3*r);return t},V.unpackArray=function(e,t){var n=e.length;A.defined(t)?t.length=n/3:t=new Array(n/3);for(var a=0;a<n;a+=3){var r=a/3;t[r]=V.unpack(e,a,t[r])}return t},V.fromArray=V.unpack,V.maximumComponent=function(e){return Math.max(e.x,e.y,e.z)},V.minimumComponent=function(e){return Math.min(e.x,e.y,e.z)},V.minimumByComponent=function(e,t,n){return n.x=Math.min(e.x,t.x),n.y=Math.min(e.y,t.y),n.z=Math.min(e.z,t.z),n},V.maximumByComponent=function(e,t,n){return n.x=Math.max(e.x,t.x),n.y=Math.max(e.y,t.y),n.z=Math.max(e.z,t.z),n},V.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y+e.z*e.z},V.magnitude=function(e){return Math.sqrt(V.magnitudeSquared(e))};var n=new V;V.distance=function(e,t){return V.subtract(e,t,n),V.magnitude(n)},V.distanceSquared=function(e,t){return V.subtract(e,t,n),V.magnitudeSquared(n)},V.normalize=function(e,t){var n=V.magnitude(e);return t.x=e.x/n,t.y=e.y/n,t.z=e.z/n,t},V.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},V.multiplyComponents=function(e,t,n){return n.x=e.x*t.x,n.y=e.y*t.y,n.z=e.z*t.z,n},V.divideComponents=function(e,t,n){return n.x=e.x/t.x,n.y=e.y/t.y,n.z=e.z/t.z,n},V.add=function(e,t,n){return n.x=e.x+t.x,n.y=e.y+t.y,n.z=e.z+t.z,n},V.subtract=function(e,t,n){return n.x=e.x-t.x,n.y=e.y-t.y,n.z=e.z-t.z,n},V.multiplyByScalar=function(e,t,n){return n.x=e.x*t,n.y=e.y*t,n.z=e.z*t,n},V.divideByScalar=function(e,t,n){return n.x=e.x/t,n.y=e.y/t,n.z=e.z/t,n},V.negate=function(e,t){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t},V.abs=function(e,t){return t.x=Math.abs(e.x),t.y=Math.abs(e.y),t.z=Math.abs(e.z),t};var r=new V;V.lerp=function(e,t,n,a){return V.multiplyByScalar(t,n,r),a=V.multiplyByScalar(e,1-n,a),V.add(r,a,a)};var u=new V,o=new V;V.angleBetween=function(e,t){V.normalize(e,u),V.normalize(t,o);var n=V.dot(u,o),a=V.magnitude(V.cross(u,o,u));return Math.atan2(a,n)};var a=new V;V.mostOrthogonalAxis=function(e,t){var n=V.normalize(e,a);return V.abs(n,n),t=n.x<=n.y?n.x<=n.z?V.clone(V.UNIT_X,t):V.clone(V.UNIT_Z,t):n.y<=n.z?V.clone(V.UNIT_Y,t):V.clone(V.UNIT_Z,t)},V.projectVector=function(e,t,n){var a=V.dot(e,t)/V.dot(t,t);return V.multiplyByScalar(t,a,n)},V.equals=function(e,t){return e===t||A.defined(e)&&A.defined(t)&&e.x===t.x&&e.y===t.y&&e.z===t.z},V.equalsArray=function(e,t,n){return e.x===t[n]&&e.y===t[n+1]&&e.z===t[n+2]},V.equalsEpsilon=function(e,t,n,a){return e===t||A.defined(e)&&A.defined(t)&&b.CesiumMath.equalsEpsilon(e.x,t.x,n,a)&&b.CesiumMath.equalsEpsilon(e.y,t.y,n,a)&&b.CesiumMath.equalsEpsilon(e.z,t.z,n,a)},V.cross=function(e,t,n){var a=e.x,r=e.y,i=e.z,u=t.x,o=t.y,d=t.z,s=r*d-i*o,h=i*u-a*d,l=a*o-r*u;return n.x=s,n.y=h,n.z=l,n},V.midpoint=function(e,t,n){return n.x=.5*(e.x+t.x),n.y=.5*(e.y+t.y),n.z=.5*(e.z+t.z),n},V.fromDegrees=function(e,t,n,a,r){return e=b.CesiumMath.toRadians(e),t=b.CesiumMath.toRadians(t),V.fromRadians(e,t,n,a,r)},V.fromCGCS2000Degrees=function(e,t,n,a){return e=b.CesiumMath.toRadians(e),t=b.CesiumMath.toRadians(t),V.fromcgcs2000Radians(e,t,n,a)};var d=new V,s=new V,h=new V(40680631590769,40680631590769,40408299984661.445),l=new V(40680631590769,40680631590769,40408299983328.77);V.fromcgcs2000Radians=function(e,t,n,a){n=A.defaultValue(n,0);var r=l,i=Math.cos(t);d.x=i*Math.cos(e),d.y=i*Math.sin(e),d.z=Math.sin(t),d=V.normalize(d,d),V.multiplyComponents(r,d,s);var u=Math.sqrt(V.dot(d,s));return s=V.divideByScalar(s,u,s),d=V.multiplyByScalar(d,n,d),A.defined(a)||(a=new V),V.add(s,d,a)};d=new V,s=new V,h=new V(40680631590769,40680631590769,40408299984661.445);V.fromRadians=function(e,t,n,a,r){n=A.defaultValue(n,0);var i=A.defined(a)?a.radiiSquared:h,u=Math.cos(t);d.x=u*Math.cos(e),d.y=u*Math.sin(e),d.z=Math.sin(t),d=V.normalize(d,d),V.multiplyComponents(i,d,s);var o=Math.sqrt(V.dot(d,s));return s=V.divideByScalar(s,o,s),d=V.multiplyByScalar(d,n,d),A.defined(r)||(r=new V),V.add(s,d,r)},V.fromDegreesArray=function(e,t,n){var a=e.length;A.defined(n)?n.length=a/2:n=new Array(a/2);for(var r=0;r<a;r+=2){var i=e[r],u=e[r+1],o=r/2;n[o]=V.fromDegrees(i,u,0,t,n[o])}return n},V.fromRadiansArray=function(e,t,n){var a=e.length;A.defined(n)?n.length=a/2:n=new Array(a/2);for(var r=0;r<a;r+=2){var i=e[r],u=e[r+1],o=r/2;n[o]=V.fromRadians(i,u,0,t,n[o])}return n},V.fromDegreesArrayHeights=function(e,t,n){var a=e.length;A.defined(n)?n.length=a/3:n=new Array(a/3);for(var r=0;r<a;r+=3){var i=e[r],u=e[r+1],o=e[r+2],d=r/3;n[d]=V.fromDegrees(i,u,o,t,n[d])}return n},V.fromRadiansArrayHeights=function(e,t,n){var a=e.length;A.defined(n)?n.length=a/3:n=new Array(a/3);for(var r=0;r<a;r+=3){var i=e[r],u=e[r+1],o=e[r+2],d=r/3;n[d]=V.fromRadians(i,u,o,t,n[d])}return n},V.ZERO=Object.freeze(new V(0,0,0)),V.UNIT_X=Object.freeze(new V(1,0,0)),V.UNIT_Y=Object.freeze(new V(0,1,0)),V.UNIT_Z=Object.freeze(new V(0,0,1)),V.prototype.clone=function(e){return V.clone(this,e)},V.prototype.equals=function(e){return V.equals(this,e)},V.prototype.equalsEpsilon=function(e,t,n){return V.equalsEpsilon(this,e,t,n)},V.prototype.toString=function(){return"("+this.x+", "+this.y+", "+this.z+")"};var I=new V,E=new V;function f(e,t,n,a,r){var i=e.x,u=e.y,o=e.z,d=t.x,s=t.y,h=t.z,l=i*i*d*d,f=u*u*s*s,c=o*o*h*h,m=l+f+c,y=Math.sqrt(1/m),p=V.multiplyByScalar(e,y,I);if(m<a)return isFinite(y)?V.clone(p,r):void 0;var g=n.x,M=n.y,x=n.z,w=E;w.x=p.x*g*2,w.y=p.y*M*2,w.z=p.z*x*2;var v,C,_,z,S,q,O,T=(1-y)*V.magnitude(e)/(.5*V.magnitude(w)),R=0;do{R=(v=l*(S=(C=1/(1+(T-=R)*g))*C)+f*(q=(_=1/(1+T*M))*_)+c*(O=(z=1/(1+T*x))*z)-1)/(-2*(l*(S*C)*g+f*(q*_)*M+c*(O*z)*x))}while(Math.abs(v)>b.CesiumMath.EPSILON12);return A.defined(r)?(r.x=i*C,r.y=u*_,r.z=o*z,r):new V(i*C,u*_,o*z)}function c(e,t,n){this.longitude=A.defaultValue(e,0),this.latitude=A.defaultValue(t,0),this.height=A.defaultValue(n,0)}c.fromRadians=function(e,t,n,a){return n=A.defaultValue(n,0),A.defined(a)?(a.longitude=e,a.latitude=t,a.height=n,a):new c(e,t,n)},c.fromDegrees=function(e,t,n,a){return e=b.CesiumMath.toRadians(e),t=b.CesiumMath.toRadians(t),c.fromRadians(e,t,n,a)};var m=new V,y=new V,p=new V,g=new V(1/6378137,1/6378137,1/6356752.314245179),M=new V(1/40680631590769,1/40680631590769,1/40408299984661.445),x=b.CesiumMath.EPSILON1;function w(e,t,n,a){t=A.defaultValue(t,0),n=A.defaultValue(n,0),a=A.defaultValue(a,0),e._radii=new V(t,n,a),e._radiiSquared=new V(t*t,n*n,a*a),e._radiiToTheFourth=new V(t*t*t*t,n*n*n*n,a*a*a*a),e._oneOverRadii=new V(0===t?0:1/t,0===n?0:1/n,0===a?0:1/a),e._oneOverRadiiSquared=new V(0===t?0:1/(t*t),0===n?0:1/(n*n),0===a?0:1/(a*a)),e._minimumRadius=Math.min(t,n,a),e._maximumRadius=Math.max(t,n,a),e._centerToleranceSquared=b.CesiumMath.EPSILON1,0!==e._radiiSquared.z&&(e._squaredXOverSquaredZ=e._radiiSquared.x/e._radiiSquared.z)}function v(e,t,n){this._radii=void 0,this._radiiSquared=void 0,this._radiiToTheFourth=void 0,this._oneOverRadii=void 0,this._oneOverRadiiSquared=void 0,this._minimumRadius=void 0,this._maximumRadius=void 0,this._centerToleranceSquared=void 0,this._squaredXOverSquaredZ=void 0,w(this,e,t,n)}c.fromCartesian=function(e,t,n){var a=A.defined(t)?t.oneOverRadii:g,r=A.defined(t)?t.oneOverRadiiSquared:M,i=f(e,a,r,A.defined(t)?t._centerToleranceSquared:x,y);if(A.defined(i)){var u=V.multiplyComponents(i,r,m);u=V.normalize(u,u);var o=V.subtract(e,i,p),d=Math.atan2(u.y,u.x),s=Math.asin(u.z),h=b.CesiumMath.sign(V.dot(o,e))*V.magnitude(o);return A.defined(n)?(n.longitude=d,n.latitude=s,n.height=h,n):new c(d,s,h)}},c.toCartesian=function(e,t,n){return V.fromRadians(e.longitude,e.latitude,e.height,t,n)},c.clone=function(e,t){if(A.defined(e))return A.defined(t)?(t.longitude=e.longitude,t.latitude=e.latitude,t.height=e.height,t):new c(e.longitude,e.latitude,e.height)},c.equals=function(e,t){return e===t||A.defined(e)&&A.defined(t)&&e.longitude===t.longitude&&e.latitude===t.latitude&&e.height===t.height},c.equalsEpsilon=function(e,t,n){return e===t||A.defined(e)&&A.defined(t)&&Math.abs(e.longitude-t.longitude)<=n&&Math.abs(e.latitude-t.latitude)<=n&&Math.abs(e.height-t.height)<=n},c.ZERO=Object.freeze(new c(0,0,0)),c.prototype.clone=function(e){return c.clone(this,e)},c.prototype.equals=function(e){return c.equals(this,e)},c.prototype.equalsEpsilon=function(e,t){return c.equalsEpsilon(this,e,t)},c.prototype.toString=function(){return"("+this.longitude+", "+this.latitude+", "+this.height+")"},Object.defineProperties(v.prototype,{radii:{get:function(){return this._radii}},radiiSquared:{get:function(){return this._radiiSquared}},radiiToTheFourth:{get:function(){return this._radiiToTheFourth}},oneOverRadii:{get:function(){return this._oneOverRadii}},oneOverRadiiSquared:{get:function(){return this._oneOverRadiiSquared}},minimumRadius:{get:function(){return this._minimumRadius}},maximumRadius:{get:function(){return this._maximumRadius}}}),v.clone=function(e,t){if(A.defined(e)){var n=e._radii;return A.defined(t)?(V.clone(n,t._radii),V.clone(e._radiiSquared,t._radiiSquared),V.clone(e._radiiToTheFourth,t._radiiToTheFourth),V.clone(e._oneOverRadii,t._oneOverRadii),V.clone(e._oneOverRadiiSquared,t._oneOverRadiiSquared),t._minimumRadius=e._minimumRadius,t._maximumRadius=e._maximumRadius,t._centerToleranceSquared=e._centerToleranceSquared,t):new v(n.x,n.y,n.z)}},v.fromCartesian3=function(e,t){return A.defined(t)||(t=new v),A.defined(e)&&w(t,e.x,e.y,e.z),t},v.WGS84=Object.freeze(new v(6378137,6378137,6356752.314245179)),v.CGCS2000=Object.freeze(new v(6378137,6378137,6356752.314140356)),v.UNIT_SPHERE=Object.freeze(new v(1,1,1)),v.MOON=Object.freeze(new v(b.CesiumMath.LUNAR_RADIUS,b.CesiumMath.LUNAR_RADIUS,b.CesiumMath.LUNAR_RADIUS)),v.prototype.clone=function(e){return v.clone(this,e)},v.packedLength=V.packedLength,v.pack=function(e,t,n){return n=A.defaultValue(n,0),V.pack(e._radii,t,n),t},v.unpack=function(e,t,n){t=A.defaultValue(t,0);var a=V.unpack(e,t);return v.fromCartesian3(a,n)},v.prototype.geocentricSurfaceNormal=V.normalize,v.prototype.geodeticSurfaceNormalCartographic=function(e,t){var n=e.longitude,a=e.latitude,r=Math.cos(a),i=r*Math.cos(n),u=r*Math.sin(n),o=Math.sin(a);return A.defined(t)||(t=new V),t.x=i,t.y=u,t.z=o,V.normalize(t,t)},v.prototype.geodeticSurfaceNormal=function(e,t){return A.defined(t)||(t=new V),t=V.multiplyComponents(e,this._oneOverRadiiSquared,t),V.normalize(t,t)};var C=new V,_=new V;v.prototype.cartographicToCartesian=function(e,t){var n=C,a=_;this.geodeticSurfaceNormalCartographic(e,n),V.multiplyComponents(this._radiiSquared,n,a);var r=Math.sqrt(V.dot(n,a));return V.divideByScalar(a,r,a),V.multiplyByScalar(n,e.height,n),A.defined(t)||(t=new V),V.add(a,n,t)},v.prototype.cartographicArrayToCartesianArray=function(e,t){var n=e.length;A.defined(t)?t.length=n:t=new Array(n);for(var a=0;a<n;a++)t[a]=this.cartographicToCartesian(e[a],t[a]);return t};var z=new V,S=new V,q=new V;function O(e,t,n,a){this.west=A.defaultValue(e,0),this.south=A.defaultValue(t,0),this.east=A.defaultValue(n,0),this.north=A.defaultValue(a,0)}v.prototype.cartesianToCartographic=function(e,t){var n=this.scaleToGeodeticSurface(e,S);if(A.defined(n)){var a=this.geodeticSurfaceNormal(n,z),r=V.subtract(e,n,q),i=Math.atan2(a.y,a.x),u=Math.asin(a.z),o=b.CesiumMath.sign(V.dot(r,e))*V.magnitude(r);return A.defined(t)?(t.longitude=i,t.latitude=u,t.height=o,t):new c(i,u,o)}},v.prototype.cartesianArrayToCartographicArray=function(e,t){var n=e.length;A.defined(t)?t.length=n:t=new Array(n);for(var a=0;a<n;++a)t[a]=this.cartesianToCartographic(e[a],t[a]);return t},v.prototype.scaleToGeodeticSurface=function(e,t){return f(e,this._oneOverRadii,this._oneOverRadiiSquared,this._centerToleranceSquared,t)},v.prototype.scaleToGeocentricSurface=function(e,t){A.defined(t)||(t=new V);var n=e.x,a=e.y,r=e.z,i=this._oneOverRadiiSquared,u=1/Math.sqrt(n*n*i.x+a*a*i.y+r*r*i.z);return V.multiplyByScalar(e,u,t)},v.prototype.transformPositionToScaledSpace=function(e,t){return A.defined(t)||(t=new V),V.multiplyComponents(e,this._oneOverRadii,t)},v.prototype.transformPositionFromScaledSpace=function(e,t){return A.defined(t)||(t=new V),V.multiplyComponents(e,this._radii,t)},v.prototype.equals=function(e){return this===e||A.defined(e)&&V.equals(this._radii,e._radii)},v.prototype.toString=function(){return this._radii.toString()},v.prototype.getSurfaceNormalIntersectionWithZAxis=function(e,t,n){t=A.defaultValue(t,0);var a=this._squaredXOverSquaredZ;if(A.defined(n)||(n=new V),n.x=0,n.y=0,n.z=e.z*(1-a),!(Math.abs(n.z)>=this._radii.z-t))return n},Object.defineProperties(O.prototype,{width:{get:function(){return O.computeWidth(this)}},height:{get:function(){return O.computeHeight(this)}}}),O.packedLength=4,O.pack=function(e,t,n){return n=A.defaultValue(n,0),t[n++]=e.west,t[n++]=e.south,t[n++]=e.east,t[n]=e.north,t},O.unpack=function(e,t,n){return t=A.defaultValue(t,0),A.defined(n)||(n=new O),n.west=e[t++],n.south=e[t++],n.east=e[t++],n.north=e[t],n},O.computeWidth=function(e){var t=e.east,n=e.west;return t<n&&(t+=b.CesiumMath.TWO_PI),t-n},O.computeHeight=function(e){return e.north-e.south},O.fromDegrees=function(e,t,n,a,r){return e=b.CesiumMath.toRadians(A.defaultValue(e,0)),t=b.CesiumMath.toRadians(A.defaultValue(t,0)),n=b.CesiumMath.toRadians(A.defaultValue(n,0)),a=b.CesiumMath.toRadians(A.defaultValue(a,0)),A.defined(r)?(r.west=e,r.south=t,r.east=n,r.north=a,r):new O(e,t,n,a)},O.fromRadians=function(e,t,n,a,r){return A.defined(r)?(r.west=A.defaultValue(e,0),r.south=A.defaultValue(t,0),r.east=A.defaultValue(n,0),r.north=A.defaultValue(a,0),r):new O(e,t,n,a)},O.fromCartographicArray=function(e,t){for(var n=Number.MAX_VALUE,a=-Number.MAX_VALUE,r=Number.MAX_VALUE,i=-Number.MAX_VALUE,u=Number.MAX_VALUE,o=-Number.MAX_VALUE,d=0,s=e.length;d<s;d++){var h=e[d];n=Math.min(n,h.longitude),a=Math.max(a,h.longitude),u=Math.min(u,h.latitude),o=Math.max(o,h.latitude);var l=0<=h.longitude?h.longitude:h.longitude+b.CesiumMath.TWO_PI;r=Math.min(r,l),i=Math.max(i,l)}return i-r<a-n&&(n=r,(a=i)>b.CesiumMath.PI&&(a-=b.CesiumMath.TWO_PI),n>b.CesiumMath.PI&&(n-=b.CesiumMath.TWO_PI)),A.defined(t)?(t.west=n,t.south=u,t.east=a,t.north=o,t):new O(n,u,a,o)},O.fromCartesianArray=function(e,t,n){t=A.defaultValue(t,v.WGS84);for(var a=Number.MAX_VALUE,r=-Number.MAX_VALUE,i=Number.MAX_VALUE,u=-Number.MAX_VALUE,o=Number.MAX_VALUE,d=-Number.MAX_VALUE,s=0,h=e.length;s<h;s++){var l=t.cartesianToCartographic(e[s]);a=Math.min(a,l.longitude),r=Math.max(r,l.longitude),o=Math.min(o,l.latitude),d=Math.max(d,l.latitude);var f=0<=l.longitude?l.longitude:l.longitude+b.CesiumMath.TWO_PI;i=Math.min(i,f),u=Math.max(u,f)}return u-i<r-a&&(a=i,(r=u)>b.CesiumMath.PI&&(r-=b.CesiumMath.TWO_PI),a>b.CesiumMath.PI&&(a-=b.CesiumMath.TWO_PI)),A.defined(n)?(n.west=a,n.south=o,n.east=r,n.north=d,n):new O(a,o,r,d)},O.clone=function(e,t){if(A.defined(e))return A.defined(t)?(t.west=e.west,t.south=e.south,t.east=e.east,t.north=e.north,t):new O(e.west,e.south,e.east,e.north)},O.equalsEpsilon=function(e,t,n){return e===t||A.defined(e)&&A.defined(t)&&Math.abs(e.west-t.west)<=n&&Math.abs(e.south-t.south)<=n&&Math.abs(e.east-t.east)<=n&&Math.abs(e.north-t.north)<=n},O.prototype.clone=function(e){return O.clone(this,e)},O.prototype.equals=function(e){return O.equals(this,e)},O.equals=function(e,t){return e===t||A.defined(e)&&A.defined(t)&&e.west===t.west&&e.south===t.south&&e.east===t.east&&e.north===t.north},O.prototype.equalsEpsilon=function(e,t){return O.equalsEpsilon(this,e,t)},O.validate=function(e){},O.southwest=function(e,t){return A.defined(t)?(t.longitude=e.west,t.latitude=e.south,t.height=0,t):new c(e.west,e.south)},O.northwest=function(e,t){return A.defined(t)?(t.longitude=e.west,t.latitude=e.north,t.height=0,t):new c(e.west,e.north)},O.northeast=function(e,t){return A.defined(t)?(t.longitude=e.east,t.latitude=e.north,t.height=0,t):new c(e.east,e.north)},O.southeast=function(e,t){return A.defined(t)?(t.longitude=e.east,t.latitude=e.south,t.height=0,t):new c(e.east,e.south)},O.center=function(e,t){var n=e.east,a=e.west;n<a&&(n+=b.CesiumMath.TWO_PI);var r=b.CesiumMath.negativePiToPi(.5*(a+n)),i=.5*(e.south+e.north);return A.defined(t)?(t.longitude=r,t.latitude=i,t.height=0,t):new c(r,i)},O.intersection=function(e,t,n){var a=e.east,r=e.west,i=t.east,u=t.west;a<r&&0<i?a+=b.CesiumMath.TWO_PI:i<u&&0<a&&(i+=b.CesiumMath.TWO_PI),a<r&&u<0?u+=b.CesiumMath.TWO_PI:i<u&&r<0&&(r+=b.CesiumMath.TWO_PI);var o=b.CesiumMath.negativePiToPi(Math.max(r,u)),d=b.CesiumMath.negativePiToPi(Math.min(a,i));if(!((e.west<e.east||t.west<t.east)&&d<=o)){var s=Math.max(e.south,t.south),h=Math.min(e.north,t.north);if(!(h<=s))return A.defined(n)?(n.west=o,n.south=s,n.east=d,n.north=h,n):new O(o,s,d,h)}},O.simpleIntersection=function(e,t,n){var a=Math.max(e.west,t.west),r=Math.max(e.south,t.south),i=Math.min(e.east,t.east),u=Math.min(e.north,t.north);if(!(u<=r||i<=a))return A.defined(n)?(n.west=a,n.south=r,n.east=i,n.north=u,n):new O(a,r,i,u)},O.union=function(e,t,n){A.defined(n)||(n=new O);var a=e.east,r=e.west,i=t.east,u=t.west;a<r&&0<i?a+=b.CesiumMath.TWO_PI:i<u&&0<a&&(i+=b.CesiumMath.TWO_PI),a<r&&u<0?u+=b.CesiumMath.TWO_PI:i<u&&r<0&&(r+=b.CesiumMath.TWO_PI);var o=b.CesiumMath.convertLongitudeRange(Math.min(r,u)),d=b.CesiumMath.convertLongitudeRange(Math.max(a,i));return n.west=o,n.south=Math.min(e.south,t.south),n.east=d,n.north=Math.max(e.north,t.north),n},O.expand=function(e,t,n){return A.defined(n)||(n=new O),n.west=Math.min(e.west,t.longitude),n.south=Math.min(e.south,t.latitude),n.east=Math.max(e.east,t.longitude),n.north=Math.max(e.north,t.latitude),n},O.contains=function(e,t){var n=t.longitude,a=t.latitude,r=e.west,i=e.east;return i<r&&(i+=b.CesiumMath.TWO_PI,n<0&&(n+=b.CesiumMath.TWO_PI)),(r<n||b.CesiumMath.equalsEpsilon(n,r,b.CesiumMath.EPSILON14))&&(n<i||b.CesiumMath.equalsEpsilon(n,i,b.CesiumMath.EPSILON14))&&a>=e.south&&a<=e.north};var T=new c;function R(e,t){this.x=A.defaultValue(e,0),this.y=A.defaultValue(t,0)}O.subsample=function(e,t,n,a){t=A.defaultValue(t,v.WGS84),n=A.defaultValue(n,0),A.defined(a)||(a=[]);var r=0,i=e.north,u=e.south,o=e.east,d=e.west,s=T;s.height=n,s.longitude=d,s.latitude=i,a[r]=t.cartographicToCartesian(s,a[r]),r++,s.longitude=o,a[r]=t.cartographicToCartesian(s,a[r]),r++,s.latitude=u,a[r]=t.cartographicToCartesian(s,a[r]),r++,s.longitude=d,a[r]=t.cartographicToCartesian(s,a[r]),r++,s.latitude=i<0?i:0<u?u:0;for(var h=1;h<8;++h)s.longitude=-Math.PI+h*b.CesiumMath.PI_OVER_TWO,O.contains(e,s)&&(a[r]=t.cartographicToCartesian(s,a[r]),r++);return 0===s.latitude&&(s.longitude=d,a[r]=t.cartographicToCartesian(s,a[r]),r++,s.longitude=o,a[r]=t.cartographicToCartesian(s,a[r]),r++),a.length=r,a},O.MAX_VALUE=Object.freeze(new O(-Math.PI,-b.CesiumMath.PI_OVER_TWO,Math.PI,b.CesiumMath.PI_OVER_TWO)),R.fromElements=function(e,t,n){return A.defined(n)?(n.x=e,n.y=t,n):new R(e,t)},R.fromCartesian3=R.clone=function(e,t){if(A.defined(e))return A.defined(t)?(t.x=e.x,t.y=e.y,t):new R(e.x,e.y)},R.fromCartesian4=R.clone,R.packedLength=2,R.pack=function(e,t,n){return n=A.defaultValue(n,0),t[n++]=e.x,t[n]=e.y,t},R.unpack=function(e,t,n){return t=A.defaultValue(t,0),A.defined(n)||(n=new R),n.x=e[t++],n.y=e[t],n},R.packArray=function(e,t){var n=e.length,a=2*n;if(A.defined(t)){if(!Array.isArray(t)&&t.length!==a)throw new i.DeveloperError("If result is a typed array, it must have exactly array.length * 2 elements");t.length!==a&&(t.length=a)}else t=new Array(a);for(var r=0;r<n;++r)R.pack(e[r],t,2*r);return t},R.unpackArray=function(e,t){var n=e.length;A.defined(t)?t.length=n/2:t=new Array(n/2);for(var a=0;a<n;a+=2){var r=a/2;t[r]=R.unpack(e,a,t[r])}return t},R.fromArray=R.unpack,R.maximumComponent=function(e){return Math.max(e.x,e.y)},R.minimumComponent=function(e){return Math.min(e.x,e.y)},R.minimumByComponent=function(e,t,n){return n.x=Math.min(e.x,t.x),n.y=Math.min(e.y,t.y),n},R.maximumByComponent=function(e,t,n){return n.x=Math.max(e.x,t.x),n.y=Math.max(e.y,t.y),n},R.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},R.magnitude=function(e){return Math.sqrt(R.magnitudeSquared(e))};var P=new R;R.distance=function(e,t){return R.subtract(e,t,P),R.magnitude(P)},R.distanceSquared=function(e,t){return R.subtract(e,t,P),R.magnitudeSquared(P)},R.normalize=function(e,t){var n=R.magnitude(e);return t.x=e.x/n,t.y=e.y/n,t},R.dot=function(e,t){return e.x*t.x+e.y*t.y},R.multiplyComponents=function(e,t,n){return n.x=e.x*t.x,n.y=e.y*t.y,n},R.divideComponents=function(e,t,n){return n.x=e.x/t.x,n.y=e.y/t.y,n},R.add=function(e,t,n){return n.x=e.x+t.x,n.y=e.y+t.y,n},R.subtract=function(e,t,n){return n.x=e.x-t.x,n.y=e.y-t.y,n},R.multiplyByScalar=function(e,t,n){return n.x=e.x*t,n.y=e.y*t,n},R.divideByScalar=function(e,t,n){return n.x=e.x/t,n.y=e.y/t,n},R.negate=function(e,t){return t.x=-e.x,t.y=-e.y,t},R.abs=function(e,t){return t.x=Math.abs(e.x),t.y=Math.abs(e.y),t};var N=new R;R.lerp=function(e,t,n,a){return R.multiplyByScalar(t,n,N),a=R.multiplyByScalar(e,1-n,a),R.add(N,a,a)};var U=new R,L=new R;R.angleBetween=function(e,t){return R.normalize(e,U),R.normalize(t,L),b.CesiumMath.acosClamped(R.dot(U,L))};var k=new R;R.mostOrthogonalAxis=function(e,t){var n=R.normalize(e,k);return R.abs(n,n),t=n.x<=n.y?R.clone(R.UNIT_X,t):R.clone(R.UNIT_Y,t)},R.equals=function(e,t){return e===t||A.defined(e)&&A.defined(t)&&e.x===t.x&&e.y===t.y},R.equalsArray=function(e,t,n){return e.x===t[n]&&e.y===t[n+1]},R.equalsEpsilon=function(e,t,n,a){return e===t||A.defined(e)&&A.defined(t)&&b.CesiumMath.equalsEpsilon(e.x,t.x,n,a)&&b.CesiumMath.equalsEpsilon(e.y,t.y,n,a)},R.ZERO=Object.freeze(new R(0,0)),R.UNIT_X=Object.freeze(new R(1,0)),R.UNIT_Y=Object.freeze(new R(0,1)),R.prototype.clone=function(e){return R.clone(this,e)},R.prototype.equals=function(e){return R.equals(this,e)},R.prototype.equalsEpsilon=function(e,t,n){return R.equalsEpsilon(this,e,t,n)},R.prototype.toString=function(){return"("+this.x+", "+this.y+")"},e.Cartesian2=R,e.Cartesian3=V,e.Cartographic=c,e.Ellipsoid=v,e.Rectangle=O});
|