/** * Cesium - https://github.com/CesiumGS/cesium * * Copyright 2011-2020 Cesium Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Columbus View (Pat. Pend.) * * Portions licensed separately. * See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details. */ define(["exports","./when-8d13db60","./Check-70bec281","./Math-61ede240"],function(e,R,S,N){function A(e,t,n){this.x=R.defaultValue(e,0),this.y=R.defaultValue(t,0),this.z=R.defaultValue(n,0)}A.fromSpherical=function(e,t){S.Check.typeOf.object("spherical",e),R.defined(t)||(t=new A);var n=e.clock,r=e.cone,a=R.defaultValue(e.magnitude,1),i=a*Math.sin(r);return t.x=i*Math.cos(n),t.y=i*Math.sin(n),t.z=a*Math.cos(r),t},A.fromElements=function(e,t,n,r){return R.defined(r)?(r.x=e,r.y=t,r.z=n,r):new A(e,t,n)},A.fromCartesian4=A.clone=function(e,t){if(R.defined(e))return R.defined(t)?(t.x=e.x,t.y=e.y,t.z=e.z,t):new A(e.x,e.y,e.z)},A.packedLength=3,A.pack=function(e,t,n){return S.Check.typeOf.object("value",e),S.Check.defined("array",t),n=R.defaultValue(n,0),t[n++]=e.x,t[n++]=e.y,t[n]=e.z,t},A.unpack=function(e,t,n){return S.Check.defined("array",e),t=R.defaultValue(t,0),R.defined(n)||(n=new A),n.x=e[t++],n.y=e[t++],n.z=e[t],n},A.packArray=function(e,t){S.Check.defined("array",e);var n=e.length;R.defined(t)?t.length=3*n:t=new Array(3*n);for(var r=0;rN.CesiumMath.EPSILON12);return R.defined(a)?(a.x=i*z,a.y=o*x,a.z=u*w,a):new A(i*z,o*x,u*w)}function s(e,t,n){this.longitude=R.defaultValue(e,0),this.latitude=R.defaultValue(t,0),this.height=R.defaultValue(n,0)}s.fromRadians=function(e,t,n,r){return S.Check.typeOf.number("longitude",e),S.Check.typeOf.number("latitude",t),n=R.defaultValue(n,0),R.defined(r)?(r.longitude=e,r.latitude=t,r.height=n,r):new s(e,t,n)},s.fromDegrees=function(e,t,n,r){return S.Check.typeOf.number("longitude",e),S.Check.typeOf.number("latitude",t),e=N.CesiumMath.toRadians(e),t=N.CesiumMath.toRadians(t),s.fromRadians(e,t,n,r)};var y=new A,p=new A,m=new A,C=new A(1/6378137,1/6378137,1/6356752.314245179),b=new A(1/6378137,1/6378137,1/6378137),g=new A(1/40680631590769,1/40680631590769,1/40408299984661.445),k=new A(1/40680631590769,1/40680631590769,1/40680631590769),O=N.CesiumMath.EPSILON1;s.fromCartesian=function(e,t,n){var r=R.defined(t)?t.oneOverRadii:b,a=R.defined(t)?t.oneOverRadiiSquared:k,i=R.defined(t)?t._centerToleranceSquared:O;N.CesiumMath.equalsEpsilon(N.CesiumMath.Radius,6356752.314245179,N.CesiumMath.EPSILON10)&&(r=R.defined(t)?t.oneOverRadii:C,a=R.defined(t)?t.oneOverRadiiSquared:g);var o=l(e,r,a,i,p);if(R.defined(o)){var u=A.multiplyComponents(o,a,y);u=A.normalize(u,u);var c=A.subtract(e,o,m),f=Math.atan2(u.y,u.x),d=Math.asin(u.z),h=N.CesiumMath.sign(A.dot(c,e))*A.magnitude(c);return R.defined(n)?(n.longitude=f,n.latitude=d,n.height=h,n):new s(f,d,h)}},s.toCartesian=function(e,t,n){return S.Check.defined("cartographic",e),A.fromRadians(e.longitude,e.latitude,e.height,t,n)},s.sphericalDistance=function(e,t,n,r){if(S.Check.defined("longitudeA",e),S.Check.defined("longitudeB",n),S.Check.defined("latitudeA",t),S.Check.defined("latitudeB",r),e===n&&t===r)return 0;var a=N.CesiumMath.toRadians(t),i=N.CesiumMath.toRadians(r),o=N.CesiumMath.toRadians(e),u=N.CesiumMath.toRadians(n),c=o*o+a*a,f=u*u+i*i,d=(c+f-((o-u)*(o-u)+(a-i)*(a-i)))/(2*Math.sqrt(c)*Math.sqrt(f));return d=N.CesiumMath.clamp(d,-1,1),Math.acos(d)*N.CesiumMath.Radius},s.clone=function(e,t){if(R.defined(e))return R.defined(t)?(t.longitude=e.longitude,t.latitude=e.latitude,t.height=e.height,t):new s(e.longitude,e.latitude,e.height)},s.equals=function(e,t){return e===t||R.defined(e)&&R.defined(t)&&e.longitude===t.longitude&&e.latitude===t.latitude&&e.height===t.height},s.equalsEpsilon=function(e,t,n){return S.Check.typeOf.number("epsilon",n),e===t||R.defined(e)&&R.defined(t)&&Math.abs(e.longitude-t.longitude)<=n&&Math.abs(e.latitude-t.latitude)<=n&&Math.abs(e.height-t.height)<=n},s.ZERO=Object.freeze(new s(0,0,0)),s.prototype.clone=function(e){return s.clone(this,e)},s.prototype.equals=function(e){return s.equals(this,e)},s.prototype.equalsEpsilon=function(e,t){return s.equalsEpsilon(this,e,t)},s.prototype.toString=function(){return"("+this.longitude+", "+this.latitude+", "+this.height+")"},e.Cartesian3=A,e.Cartographic=s,e.scaleToGeodeticSurface=l});