1 |
- define(["exports","./AxisAlignedBoundingBox-883f9c89","./Matrix2-ccd5b911","./RuntimeError-346a3079","./when-4bbc8319","./IntersectionTests-4d6f5c54","./Plane-18bb00f8","./Transforms-d5c6ad6e"],function(t,n,s,e,l,i,r,a){"use strict";var o=new s.Cartesian4;function d(t,e){t=(e=l.defaultValue(e,s.Ellipsoid.WGS84)).scaleToGeodeticSurface(t);var n=a.Transforms.eastNorthUpToFixedFrame(t,e);this._ellipsoid=e,this._origin=t,this._xAxis=s.Cartesian3.fromCartesian4(s.Matrix4.getColumn(n,0,o)),this._yAxis=s.Cartesian3.fromCartesian4(s.Matrix4.getColumn(n,1,o));n=s.Cartesian3.fromCartesian4(s.Matrix4.getColumn(n,2,o));this._plane=r.Plane.fromPointNormal(t,n)}Object.defineProperties(d.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 c=new n.AxisAlignedBoundingBox;d.fromPoints=function(t,e){return new d(n.AxisAlignedBoundingBox.fromPoints(t,c).center,e)};var p=new i.Ray,f=new s.Cartesian3;d.prototype.projectPointOntoPlane=function(t,e){var n=p;n.origin=t,s.Cartesian3.normalize(t,n.direction);t=i.IntersectionTests.rayPlane(n,this._plane,f);if(l.defined(t)||(s.Cartesian3.negate(n.direction,n.direction),t=i.IntersectionTests.rayPlane(n,this._plane,f)),l.defined(t)){n=s.Cartesian3.subtract(t,this._origin,t),t=s.Cartesian3.dot(this._xAxis,n),n=s.Cartesian3.dot(this._yAxis,n);return l.defined(e)?(e.x=t,e.y=n,e):new s.Cartesian2(t,n)}},d.prototype.projectPointsOntoPlane=function(t,e){l.defined(e)||(e=[]);for(var n=0,i=t.length,r=0;r<i;r++){var a=this.projectPointOntoPlane(t[r],e[n]);l.defined(a)&&(e[n]=a,n++)}return e.length=n,e},d.prototype.projectPointToNearestOnPlane=function(t,e){l.defined(e)||(e=new s.Cartesian2);var n=p;n.origin=t,s.Cartesian3.clone(this._plane.normal,n.direction);t=i.IntersectionTests.rayPlane(n,this._plane,f);l.defined(t)||(s.Cartesian3.negate(n.direction,n.direction),t=i.IntersectionTests.rayPlane(n,this._plane,f));n=s.Cartesian3.subtract(t,this._origin,t),t=s.Cartesian3.dot(this._xAxis,n),n=s.Cartesian3.dot(this._yAxis,n);return e.x=t,e.y=n,e},d.prototype.projectPointsToNearestOnPlane=function(t,e){l.defined(e)||(e=[]);var n=t.length;e.length=n;for(var i=0;i<n;i++)e[i]=this.projectPointToNearestOnPlane(t[i],e[i]);return e};var u=new s.Cartesian3;d.prototype.projectPointOntoEllipsoid=function(t,e){l.defined(e)||(e=new s.Cartesian3);var n=this._ellipsoid,i=this._origin,r=this._xAxis,a=this._yAxis,o=u;return s.Cartesian3.multiplyByScalar(r,t.x,o),e=s.Cartesian3.add(i,o,e),s.Cartesian3.multiplyByScalar(a,t.y,o),s.Cartesian3.add(e,o,e),n.scaleToGeocentricSurface(e,e),e},d.prototype.projectPointsOntoEllipsoid=function(t,e){var n=t.length;l.defined(e)?e.length=n:e=new Array(n);for(var i=0;i<n;++i)e[i]=this.projectPointOntoEllipsoid(t[i],e[i]);return e},t.EllipsoidTangentPlane=d});
|