define(["exports","./Cartesian2-b4b7b0b3","./when-208fe5b0","./Check-5e798bbf","./Transforms-73e77b72","./Math-8386669c","./GeometryAttribute-b541caa6"],function(t,X,w,n,a,Y,l){"use strict";var d=Math.cos,M=Math.sin,m=Math.sqrt,r={computePosition:function(t,n,a,r,e,o,s){var i=n.radiiSquared,g=t.nwCorner,h=t.boundingRectangle,u=g.latitude-t.granYCos*r+e*t.granXSin,c=d(u),C=M(u),l=i.z*C,S=g.longitude+r*t.granYSin+e*t.granXCos,n=c*d(S),g=c*M(S),c=i.x*n,i=i.y*g,C=m(c*n+i*g+l*C);o.x=c/C,o.y=i/C,o.z=l/C,a&&(a=t.stNwCorner,w.defined(a)?(u=a.latitude-t.stGranYCos*r+e*t.stGranXSin,S=a.longitude+r*t.stGranYSin+e*t.stGranXCos,s.x=(S-t.stWest)*t.lonScalar,s.y=(u-t.stSouth)*t.latScalar):(s.x=(S-h.west)*t.lonScalar,s.y=(u-h.south)*t.latScalar))}},S=new l.Matrix2,b=new X.Cartesian3,p=new X.Cartographic,G=new X.Cartesian3,f=new a.GeographicProjection;function x(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;b=f.project(t,b),b=X.Cartesian3.subtract(b,G,b);i=l.Matrix2.fromRotation(n,S);b=l.Matrix2.multiplyByVector(i,b,b),b=X.Cartesian3.add(b,G,b);r=(t=f.unproject(b,t)).latitude,a=r+--o*C,u=r-g*--s,n=r-g*s+o*C,i=Math.max(r,a,u,n),r=Math.min(r,a,u,n),a=t.longitude,u=a+o*h,n=a+s*c,o=a+s*c+o*h;return{north:i,south:r,east:Math.max(a,u,n,o),west:Math.min(a,u,n,o),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===Y.CesiumMath.PI_OVER_TWO&&(c=!0),u===-Y.CesiumMath.PI_OVER_TWO&&(C=!0);var l,S=h-u,w=(d=i<g?Y.CesiumMath.TWO_PI-g+i:i-g)/((l=Math.ceil(d/n)+1)-1),d=S/((M=Math.ceil(S/n)+1)-1),S=X.Rectangle.northwest(t,o),n=X.Rectangle.center(t,p);0===a&&0===r||(n.longitude<S.longitude&&(n.longitude+=Y.CesiumMath.TWO_PI),G=f.project(n,G));var M,o=d,n=w,e=X.Rectangle.clone(t,e),C={granYCos:o,granYSin:0,granXCos:n,granXSin:0,nwCorner:S,boundingRectangle:e,width:l,height:M,northCap:c,southCap:C};return 0!==a&&(h=(S=x(S,a,w,d,0,l,M)).north,u=S.south,i=S.east,g=S.west,C.granYCos=S.granYCos,C.granYSin=S.granYSin,C.granXCos=S.granXCos,C.granXSin=S.granXSin,e.north=h,e.south=u,e.east=i,e.west=g),0!==r&&(a-=r,M=x(s=X.Rectangle.northwest(e,s),a,w,d,0,l,M),C.stGranYCos=M.granYCos,C.stGranXCos=M.granXCos,C.stGranYSin=M.granYSin,C.stGranXSin=M.granXSin,C.stNwCorner=s,C.stWest=M.west,C.stSouth=M.south),C},t.RectangleGeometryLibrary=r});
