define(["exports","./Cartographic-1d953166","./Check-2514d21d","./when-d186add7","./buildModuleUrl-d920237a","./Cartesian2-2b41fabe","./Cartesian4-3408960c","./Rectangle-f841217d","./IntersectionTests-300d4352","./FeatureDetection-4281d393","./Plane-d9914d3c","./GeometryAttribute-95780fd1"],(function(t,e,n,i,r,o,a,s,m,c,u,l){"use strict";function d(t,n,r){this.minimum=e.t.clone(i.u(t,e.t.ZERO)),this.maximum=e.t.clone(i.u(n,e.t.ZERO)),r=i.e(r)?e.t.clone(r):e.t.midpoint(this.minimum,this.maximum,new e.t),this.center=r}d.fromPoints=function(t,n){if(i.e(n)||(n=new d),!i.e(t)||0===t.length)return n.minimum=e.t.clone(e.t.ZERO,n.minimum),n.maximum=e.t.clone(e.t.ZERO,n.maximum),n.center=e.t.clone(e.t.ZERO,n.center),n;for(var r=t[0].x,o=t[0].y,a=t[0].z,s=t[0].x,m=t[0].y,c=t[0].z,u=t.length,l=1;l<u;l++){var h=t[l],f=h.x,p=h.y,x=h.z;r=Math.min(f,r),s=Math.max(f,s),o=Math.min(p,o),m=Math.max(p,m),a=Math.min(x,a),c=Math.max(x,c)}var y=n.minimum;y.x=r,y.y=o,y.z=a;var g=n.maximum;return g.x=s,g.y=m,g.z=c,n.center=e.t.midpoint(y,g,n.center),n},d.clone=function(t,n){if(i.e(t))return i.e(n)?(n.minimum=e.t.clone(t.minimum,n.minimum),n.maximum=e.t.clone(t.maximum,n.maximum),n.center=e.t.clone(t.center,n.center),n):new d(t.minimum,t.maximum,t.center)},d.equals=function(t,n){return t===n||i.e(t)&&i.e(n)&&e.t.equals(t.center,n.center)&&e.t.equals(t.minimum,n.minimum)&&e.t.equals(t.maximum,n.maximum)};var h=new e.t;d.intersectPlane=function(t,i){n.o.defined("box",t),n.o.defined("plane",i),h=e.t.subtract(t.maximum,t.minimum,h);var o=e.t.multiplyByScalar(h,.5,h),a=i.normal,s=o.x*Math.abs(a.x)+o.y*Math.abs(a.y)+o.z*Math.abs(a.z),m=e.t.dot(t.center,a)+i.distance;return m-s>0?r.S.INSIDE:m+s<0?r.S.OUTSIDE:r.S.INTERSECTING},d.prototype.clone=function(t){return d.clone(this,t)},d.prototype.intersectPlane=function(t){return d.intersectPlane(this,t)},d.prototype.equals=function(t){return d.equals(this,t)};var f=new a.e;function p(t,r){if(n.o.defined("origin",t),t=(r=i.u(r,s.t.WGS84)).scaleToGeodeticSurface(t),!i.e(t))throw new n.t("origin must not be at the center of the ellipsoid.");var o=l.m.eastNorthUpToFixedFrame(t,r);this._ellipsoid=r,this._origin=t,this._xAxis=e.t.fromCartesian4(c.y.getColumn(o,0,f)),this._yAxis=e.t.fromCartesian4(c.y.getColumn(o,1,f));var a=e.t.fromCartesian4(c.y.getColumn(o,2,f));this._plane=u.o.fromPointNormal(t,a)}Object.defineProperties(p.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},origin:{get:function(){return this._origin}},plane:{get:function(){return this._plane}},xAxis:{get:function(){return this._xAxis}},yAxis:{get:function(){return this._yAxis}},zAxis:{get:function(){return this._plane.normal}}});var x=new d;p.fromPoints=function(t,e){return n.o.defined("cartesians",t),new p(d.fromPoints(t,x).center,e)};var y=new m.f,g=new e.t;p.prototype.projectPointOntoPlane=function(t,r){n.o.defined("cartesian",t);var a=y;a.origin=t,e.t.normalize(t,a.direction);var s=m.g.rayPlane(a,this._plane,g);if(i.e(s)||(e.t.negate(a.direction,a.direction),s=m.g.rayPlane(a,this._plane,g)),i.e(s)){var c=e.t.subtract(s,this._origin,s),u=e.t.dot(this._xAxis,c),l=e.t.dot(this._yAxis,c);return i.e(r)?(r.x=u,r.y=l,r):new o.o(u,l)}},p.prototype.projectPointsOntoPlane=function(t,e){n.o.defined("cartesians",t),i.e(e)||(e=[]);for(var r=0,o=t.length,a=0;a<o;a++){var s=this.projectPointOntoPlane(t[a],e[r]);i.e(s)&&(e[r]=s,r++)}return e.length=r,e},p.prototype.projectPointToNearestOnPlane=function(t,r){n.o.defined("cartesian",t),i.e(r)||(r=new o.o);var a=y;a.origin=t,e.t.clone(this._plane.normal,a.direction);var s=m.g.rayPlane(a,this._plane,g);i.e(s)||(e.t.negate(a.direction,a.direction),s=m.g.rayPlane(a,this._plane,g));var c=e.t.subtract(s,this._origin,s),u=e.t.dot(this._xAxis,c),l=e.t.dot(this._yAxis,c);return r.x=u,r.y=l,r},p.prototype.projectPointsToNearestOnPlane=function(t,e){n.o.defined("cartesians",t),i.e(e)||(e=[]);var r=t.length;e.length=r;for(var o=0;o<r;o++)e[o]=this.projectPointToNearestOnPlane(t[o],e[o]);return e};var P=new e.t;p.prototype.projectPointOntoEllipsoid=function(t,r){n.o.defined("cartesian",t),i.e(r)||(r=new e.t);var o=this._ellipsoid,a=this._origin,s=this._xAxis,m=this._yAxis,c=P;return e.t.multiplyByScalar(s,t.x,c),r=e.t.add(a,c,r),e.t.multiplyByScalar(m,t.y,c),e.t.add(r,c,r),o.scaleToGeocentricSurface(r,r),r},p.prototype.projectPointsOntoEllipsoid=function(t,e){n.o.defined("cartesians",t);var r=t.length;i.e(e)?e.length=r:e=new Array(r);for(var o=0;o<r;++o)e[o]=this.projectPointOntoEllipsoid(t[o],e[o]);return e},t.e=d,t.f=p}));
