define(["exports","./when-cbf8cd21","./Check-35e1a91d","./Math-e66fad2a","./Cartesian2-44433f55","./Transforms-d9350502","./GeometryAttribute-424f2c6a"],function(t,f,n,O,b,a,x){"use strict";var p=Math.cos,G=Math.sin,R=Math.sqrt,r={computePosition:function(t,n,a,r,e,o,s){var i,g=n.radiiSquared,h=t.nwCorner,u=t.boundingRectangle,c=h.latitude-t.granYCos*r+e*t.granXSin,C=p(c),l=G(c),d=g.z*l,S=h.longitude+r*t.granYSin+e*t.granXCos,w=C*p(S),M=C*G(S),X=g.x*w,Y=g.y*M,m=R(X*w+Y*M+d*l);o.x=X/m,o.y=Y/m,o.z=d/m,a&&(i=t.stNwCorner,f.defined(i)?(c=i.latitude-t.stGranYCos*r+e*t.stGranXSin,S=i.longitude+r*t.stGranYSin+e*t.stGranXCos,s.x=(S-t.stWest)*t.lonScalar,s.y=(c-t.stSouth)*t.latScalar):(s.x=(S-u.west)*t.lonScalar,s.y=(c-u.south)*t.latScalar))}},y=new x.Matrix2,v=new b.Cartesian3,P=new b.Cartographic,W=new b.Cartesian3,_=new a.GeographicProjection;function T(t,n,a,r,e,o,s){var i=Math.cos(n),g=r*i,h=a*i,u=Math.sin(n),c=r*u,C=a*u;v=_.project(t,v),v=b.Cartesian3.subtract(v,W,v);var l=x.Matrix2.fromRotation(n,y);v=x.Matrix2.multiplyByVector(l,v,v),v=b.Cartesian3.add(v,W,v),--o,--s;var d=(t=_.unproject(v,t)).latitude,S=d+o*C,w=d-g*s,M=d-g*s+o*C,X=Math.max(d,S,w,M),Y=Math.min(d,S,w,M),m=t.longitude,f=m+o*h,p=m+s*c,G=m+s*c+o*h;return{north:X,south:Y,east:Math.max(m,f,p,G),west:Math.min(m,f,p,G),granYCos:g,granYSin:c,granXCos:h,granXSin:C,nwCorner:t}}r.computeOptions=function(t,n,a,r,e,o,s){var i=t.east,g=t.west,h=t.north,u=t.south,c=!1,C=!1;h===O.CesiumMath.PI_OVER_TWO&&(c=!0),u===-O.CesiumMath.PI_OVER_TWO&&(C=!0);var l,d,S,w=h-u,M=(l=i<g?O.CesiumMath.TWO_PI-g+i:i-g)/((d=Math.ceil(l/n)+1)-1),X=w/((S=Math.ceil(w/n)+1)-1),Y=b.Rectangle.northwest(t,o),m=b.Rectangle.center(t,P);0===a&&0===r||(m.longitude<Y.longitude&&(m.longitude+=O.CesiumMath.TWO_PI),W=_.project(m,W));var f,p,G,x=X,R=M,y=b.Rectangle.clone(t,e),v={granYCos:x,granYSin:0,granXCos:R,granXSin:0,nwCorner:Y,boundingRectangle:y,width:d,height:S,northCap:c,southCap:C};return 0!==a&&(h=(f=T(Y,a,M,X,0,d,S)).north,u=f.south,i=f.east,g=f.west,v.granYCos=f.granYCos,v.granYSin=f.granYSin,v.granXCos=f.granXCos,v.granXSin=f.granXSin,y.north=h,y.south=u,y.east=i,y.west=g),0!==r&&(a-=r,G=T(p=b.Rectangle.northwest(y,s),a,M,X,0,d,S),v.stGranYCos=G.granYCos,v.stGranXCos=G.granXCos,v.stGranYSin=G.granYSin,v.stGranXSin=G.granXSin,v.stNwCorner=p,v.stWest=G.west,v.stSouth=G.south),v},t.RectangleGeometryLibrary=r});
