EllipsoidTangentPlane-a815c96f.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /**
  2. * Cesium - https://github.com/AnalyticalGraphicsInc/cesium
  3. *
  4. * Copyright 2011-2017 Cesium Contributors
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * Columbus View (Pat. Pend.)
  19. *
  20. * Portions licensed separately.
  21. * See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
  22. */
  23. define(['exports', './when-8d13db60', './Check-70bec281', './Cartographic-fe4be337', './Cartesian2-85064f09', './BoundingSphere-775c5788', './Cartesian4-5af5bb24', './Transforms-b2e71640', './IntersectionTests-397d9494', './Plane-8390418f'], function (exports, when, Check, Cartographic, Cartesian2, BoundingSphere, Cartesian4, Transforms, IntersectionTests, Plane) { 'use strict';
  24. /**
  25. * Creates an instance of an AxisAlignedBoundingBox from the minimum and maximum points along the x, y, and z axes.
  26. * @alias AxisAlignedBoundingBox
  27. * @constructor
  28. *
  29. * @param {Cartesian3} [minimum=Cartesian3.ZERO] The minimum point along the x, y, and z axes.
  30. * @param {Cartesian3} [maximum=Cartesian3.ZERO] The maximum point along the x, y, and z axes.
  31. * @param {Cartesian3} [center] The center of the box; automatically computed if not supplied.
  32. *
  33. * @see BoundingSphere
  34. * @see BoundingRectangle
  35. */
  36. function AxisAlignedBoundingBox(minimum, maximum, center) {
  37. /**
  38. * The minimum point defining the bounding box.
  39. * @type {Cartesian3}
  40. * @default {@link Cartesian3.ZERO}
  41. */
  42. this.minimum = Cartographic.Cartesian3.clone(when.defaultValue(minimum, Cartographic.Cartesian3.ZERO));
  43. /**
  44. * The maximum point defining the bounding box.
  45. * @type {Cartesian3}
  46. * @default {@link Cartesian3.ZERO}
  47. */
  48. this.maximum = Cartographic.Cartesian3.clone(when.defaultValue(maximum, Cartographic.Cartesian3.ZERO));
  49. //If center was not defined, compute it.
  50. if (!when.defined(center)) {
  51. center = Cartographic.Cartesian3.midpoint(this.minimum, this.maximum, new Cartographic.Cartesian3());
  52. } else {
  53. center = Cartographic.Cartesian3.clone(center);
  54. }
  55. /**
  56. * The center point of the bounding box.
  57. * @type {Cartesian3}
  58. */
  59. this.center = center;
  60. }
  61. /**
  62. * Computes an instance of an AxisAlignedBoundingBox. The box is determined by
  63. * finding the points spaced the farthest apart on the x, y, and z axes.
  64. *
  65. * @param {Cartesian3[]} positions List of points that the bounding box will enclose. Each point must have a <code>x</code>, <code>y</code>, and <code>z</code> properties.
  66. * @param {AxisAlignedBoundingBox} [result] The object onto which to store the result.
  67. * @returns {AxisAlignedBoundingBox} The modified result parameter or a new AxisAlignedBoundingBox instance if one was not provided.
  68. *
  69. * @example
  70. * // Compute an axis aligned bounding box enclosing two points.
  71. * var box = Cesium.AxisAlignedBoundingBox.fromPoints([new Cesium.Cartesian3(2, 0, 0), new Cesium.Cartesian3(-2, 0, 0)]);
  72. */
  73. AxisAlignedBoundingBox.fromPoints = function(positions, result) {
  74. if (!when.defined(result)) {
  75. result = new AxisAlignedBoundingBox();
  76. }
  77. if (!when.defined(positions) || positions.length === 0) {
  78. result.minimum = Cartographic.Cartesian3.clone(Cartographic.Cartesian3.ZERO, result.minimum);
  79. result.maximum = Cartographic.Cartesian3.clone(Cartographic.Cartesian3.ZERO, result.maximum);
  80. result.center = Cartographic.Cartesian3.clone(Cartographic.Cartesian3.ZERO, result.center);
  81. return result;
  82. }
  83. var minimumX = positions[0].x;
  84. var minimumY = positions[0].y;
  85. var minimumZ = positions[0].z;
  86. var maximumX = positions[0].x;
  87. var maximumY = positions[0].y;
  88. var maximumZ = positions[0].z;
  89. var length = positions.length;
  90. for ( var i = 1; i < length; i++) {
  91. var p = positions[i];
  92. var x = p.x;
  93. var y = p.y;
  94. var z = p.z;
  95. minimumX = Math.min(x, minimumX);
  96. maximumX = Math.max(x, maximumX);
  97. minimumY = Math.min(y, minimumY);
  98. maximumY = Math.max(y, maximumY);
  99. minimumZ = Math.min(z, minimumZ);
  100. maximumZ = Math.max(z, maximumZ);
  101. }
  102. var minimum = result.minimum;
  103. minimum.x = minimumX;
  104. minimum.y = minimumY;
  105. minimum.z = minimumZ;
  106. var maximum = result.maximum;
  107. maximum.x = maximumX;
  108. maximum.y = maximumY;
  109. maximum.z = maximumZ;
  110. result.center = Cartographic.Cartesian3.midpoint(minimum, maximum, result.center);
  111. return result;
  112. };
  113. /**
  114. * Duplicates a AxisAlignedBoundingBox instance.
  115. *
  116. * @param {AxisAlignedBoundingBox} box The bounding box to duplicate.
  117. * @param {AxisAlignedBoundingBox} [result] The object onto which to store the result.
  118. * @returns {AxisAlignedBoundingBox} The modified result parameter or a new AxisAlignedBoundingBox instance if none was provided. (Returns undefined if box is undefined)
  119. */
  120. AxisAlignedBoundingBox.clone = function(box, result) {
  121. if (!when.defined(box)) {
  122. return undefined;
  123. }
  124. if (!when.defined(result)) {
  125. return new AxisAlignedBoundingBox(box.minimum, box.maximum, box.center);
  126. }
  127. result.minimum = Cartographic.Cartesian3.clone(box.minimum, result.minimum);
  128. result.maximum = Cartographic.Cartesian3.clone(box.maximum, result.maximum);
  129. result.center = Cartographic.Cartesian3.clone(box.center, result.center);
  130. return result;
  131. };
  132. /**
  133. * Compares the provided AxisAlignedBoundingBox componentwise and returns
  134. * <code>true</code> if they are equal, <code>false</code> otherwise.
  135. *
  136. * @param {AxisAlignedBoundingBox} [left] The first AxisAlignedBoundingBox.
  137. * @param {AxisAlignedBoundingBox} [right] The second AxisAlignedBoundingBox.
  138. * @returns {Boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
  139. */
  140. AxisAlignedBoundingBox.equals = function(left, right) {
  141. return (left === right) ||
  142. ((when.defined(left)) &&
  143. (when.defined(right)) &&
  144. Cartographic.Cartesian3.equals(left.center, right.center) &&
  145. Cartographic.Cartesian3.equals(left.minimum, right.minimum) &&
  146. Cartographic.Cartesian3.equals(left.maximum, right.maximum));
  147. };
  148. var intersectScratch = new Cartographic.Cartesian3();
  149. /**
  150. * Determines which side of a plane a box is located.
  151. *
  152. * @param {AxisAlignedBoundingBox} box The bounding box to test.
  153. * @param {Plane} plane The plane to test against.
  154. * @returns {Intersect} {@link Intersect.INSIDE} if the entire box is on the side of the plane
  155. * the normal is pointing, {@link Intersect.OUTSIDE} if the entire box is
  156. * on the opposite side, and {@link Intersect.INTERSECTING} if the box
  157. * intersects the plane.
  158. */
  159. AxisAlignedBoundingBox.intersectPlane = function(box, plane) {
  160. //>>includeStart('debug', pragmas.debug);
  161. Check.Check.defined('box', box);
  162. Check.Check.defined('plane', plane);
  163. //>>includeEnd('debug');
  164. intersectScratch = Cartographic.Cartesian3.subtract(box.maximum, box.minimum, intersectScratch);
  165. var h = Cartographic.Cartesian3.multiplyByScalar(intersectScratch, 0.5, intersectScratch); //The positive half diagonal
  166. var normal = plane.normal;
  167. var e = h.x * Math.abs(normal.x) + h.y * Math.abs(normal.y) + h.z * Math.abs(normal.z);
  168. var s = Cartographic.Cartesian3.dot(box.center, normal) + plane.distance; //signed distance from center
  169. if (s - e > 0) {
  170. return BoundingSphere.Intersect.INSIDE;
  171. }
  172. if (s + e < 0) {
  173. //Not in front because normals point inward
  174. return BoundingSphere.Intersect.OUTSIDE;
  175. }
  176. return BoundingSphere.Intersect.INTERSECTING;
  177. };
  178. /**
  179. * Duplicates this AxisAlignedBoundingBox instance.
  180. *
  181. * @param {AxisAlignedBoundingBox} [result] The object onto which to store the result.
  182. * @returns {AxisAlignedBoundingBox} The modified result parameter or a new AxisAlignedBoundingBox instance if one was not provided.
  183. */
  184. AxisAlignedBoundingBox.prototype.clone = function(result) {
  185. return AxisAlignedBoundingBox.clone(this, result);
  186. };
  187. /**
  188. * Determines which side of a plane this box is located.
  189. *
  190. * @param {Plane} plane The plane to test against.
  191. * @returns {Intersect} {@link Intersect.INSIDE} if the entire box is on the side of the plane
  192. * the normal is pointing, {@link Intersect.OUTSIDE} if the entire box is
  193. * on the opposite side, and {@link Intersect.INTERSECTING} if the box
  194. * intersects the plane.
  195. */
  196. AxisAlignedBoundingBox.prototype.intersectPlane = function(plane) {
  197. return AxisAlignedBoundingBox.intersectPlane(this, plane);
  198. };
  199. /**
  200. * Compares this AxisAlignedBoundingBox against the provided AxisAlignedBoundingBox componentwise and returns
  201. * <code>true</code> if they are equal, <code>false</code> otherwise.
  202. *
  203. * @param {AxisAlignedBoundingBox} [right] The right hand side AxisAlignedBoundingBox.
  204. * @returns {Boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
  205. */
  206. AxisAlignedBoundingBox.prototype.equals = function(right) {
  207. return AxisAlignedBoundingBox.equals(this, right);
  208. };
  209. var scratchCart4 = new Cartesian4.Cartesian4();
  210. /**
  211. * A plane tangent to the provided ellipsoid at the provided origin.
  212. * If origin is not on the surface of the ellipsoid, it's surface projection will be used.
  213. * If origin is at the center of the ellipsoid, an exception will be thrown.
  214. * @alias EllipsoidTangentPlane
  215. * @constructor
  216. *
  217. * @param {Cartesian3} origin The point on the surface of the ellipsoid where the tangent plane touches.
  218. * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid to use.
  219. *
  220. * @exception {DeveloperError} origin must not be at the center of the ellipsoid.
  221. */
  222. function EllipsoidTangentPlane(origin, ellipsoid) {
  223. //>>includeStart('debug', pragmas.debug);
  224. Check.Check.defined('origin', origin);
  225. //>>includeEnd('debug');
  226. ellipsoid = when.defaultValue(ellipsoid, Cartesian2.Ellipsoid.WGS84);
  227. origin = ellipsoid.scaleToGeodeticSurface(origin);
  228. //>>includeStart('debug', pragmas.debug);
  229. if (!when.defined(origin)) {
  230. throw new Check.DeveloperError('origin must not be at the center of the ellipsoid.');
  231. }
  232. //>>includeEnd('debug');
  233. var eastNorthUp = Transforms.Transforms.eastNorthUpToFixedFrame(origin, ellipsoid);
  234. this._ellipsoid = ellipsoid;
  235. this._origin = origin;
  236. this._xAxis = Cartographic.Cartesian3.fromCartesian4(BoundingSphere.Matrix4.getColumn(eastNorthUp, 0, scratchCart4));
  237. this._yAxis = Cartographic.Cartesian3.fromCartesian4(BoundingSphere.Matrix4.getColumn(eastNorthUp, 1, scratchCart4));
  238. var normal = Cartographic.Cartesian3.fromCartesian4(BoundingSphere.Matrix4.getColumn(eastNorthUp, 2, scratchCart4));
  239. this._plane = Plane.Plane.fromPointNormal(origin, normal);
  240. }
  241. Object.defineProperties(EllipsoidTangentPlane.prototype, {
  242. /**
  243. * Gets the ellipsoid.
  244. * @memberof EllipsoidTangentPlane.prototype
  245. * @type {Ellipsoid}
  246. */
  247. ellipsoid : {
  248. get : function() {
  249. return this._ellipsoid;
  250. }
  251. },
  252. /**
  253. * Gets the origin.
  254. * @memberof EllipsoidTangentPlane.prototype
  255. * @type {Cartesian3}
  256. */
  257. origin : {
  258. get : function() {
  259. return this._origin;
  260. }
  261. },
  262. /**
  263. * Gets the plane which is tangent to the ellipsoid.
  264. * @memberof EllipsoidTangentPlane.prototype
  265. * @readonly
  266. * @type {Plane}
  267. */
  268. plane : {
  269. get : function() {
  270. return this._plane;
  271. }
  272. },
  273. /**
  274. * Gets the local X-axis (east) of the tangent plane.
  275. * @memberof EllipsoidTangentPlane.prototype
  276. * @readonly
  277. * @type {Cartesian3}
  278. */
  279. xAxis : {
  280. get : function() {
  281. return this._xAxis;
  282. }
  283. },
  284. /**
  285. * Gets the local Y-axis (north) of the tangent plane.
  286. * @memberof EllipsoidTangentPlane.prototype
  287. * @readonly
  288. * @type {Cartesian3}
  289. */
  290. yAxis : {
  291. get : function() {
  292. return this._yAxis;
  293. }
  294. },
  295. /**
  296. * Gets the local Z-axis (up) of the tangent plane.
  297. * @member EllipsoidTangentPlane.prototype
  298. * @readonly
  299. * @type {Cartesian3}
  300. */
  301. zAxis : {
  302. get : function() {
  303. return this._plane.normal;
  304. }
  305. }
  306. });
  307. var tmp = new AxisAlignedBoundingBox();
  308. /**
  309. * Creates a new instance from the provided ellipsoid and the center
  310. * point of the provided Cartesians.
  311. *
  312. * @param {Cartesian3} cartesians The list of positions surrounding the center point.
  313. * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid to use.
  314. */
  315. EllipsoidTangentPlane.fromPoints = function(cartesians, ellipsoid) {
  316. //>>includeStart('debug', pragmas.debug);
  317. Check.Check.defined('cartesians', cartesians);
  318. //>>includeEnd('debug');
  319. var box = AxisAlignedBoundingBox.fromPoints(cartesians, tmp);
  320. return new EllipsoidTangentPlane(box.center, ellipsoid);
  321. };
  322. var scratchProjectPointOntoPlaneRay = new IntersectionTests.Ray();
  323. var scratchProjectPointOntoPlaneCartesian3 = new Cartographic.Cartesian3();
  324. /**
  325. * Computes the projection of the provided 3D position onto the 2D plane, radially outward from the {@link EllipsoidTangentPlane.ellipsoid} coordinate system origin.
  326. *
  327. * @param {Cartesian3} cartesian The point to project.
  328. * @param {Cartesian2} [result] The object onto which to store the result.
  329. * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if none was provided. Undefined if there is no intersection point
  330. */
  331. EllipsoidTangentPlane.prototype.projectPointOntoPlane = function(cartesian, result) {
  332. //>>includeStart('debug', pragmas.debug);
  333. Check.Check.defined('cartesian', cartesian);
  334. //>>includeEnd('debug');
  335. var ray = scratchProjectPointOntoPlaneRay;
  336. ray.origin = cartesian;
  337. Cartographic.Cartesian3.normalize(cartesian, ray.direction);
  338. var intersectionPoint = IntersectionTests.IntersectionTests.rayPlane(ray, this._plane, scratchProjectPointOntoPlaneCartesian3);
  339. if (!when.defined(intersectionPoint)) {
  340. Cartographic.Cartesian3.negate(ray.direction, ray.direction);
  341. intersectionPoint = IntersectionTests.IntersectionTests.rayPlane(ray, this._plane, scratchProjectPointOntoPlaneCartesian3);
  342. }
  343. if (when.defined(intersectionPoint)) {
  344. var v = Cartographic.Cartesian3.subtract(intersectionPoint, this._origin, intersectionPoint);
  345. var x = Cartographic.Cartesian3.dot(this._xAxis, v);
  346. var y = Cartographic.Cartesian3.dot(this._yAxis, v);
  347. if (!when.defined(result)) {
  348. return new Cartesian2.Cartesian2(x, y);
  349. }
  350. result.x = x;
  351. result.y = y;
  352. return result;
  353. }
  354. return undefined;
  355. };
  356. /**
  357. * Computes the projection of the provided 3D positions onto the 2D plane (where possible), radially outward from the global origin.
  358. * The resulting array may be shorter than the input array - if a single projection is impossible it will not be included.
  359. *
  360. * @see EllipsoidTangentPlane.projectPointOntoPlane
  361. *
  362. * @param {Cartesian3[]} cartesians The array of points to project.
  363. * @param {Cartesian2[]} [result] The array of Cartesian2 instances onto which to store results.
  364. * @returns {Cartesian2[]} The modified result parameter or a new array of Cartesian2 instances if none was provided.
  365. */
  366. EllipsoidTangentPlane.prototype.projectPointsOntoPlane = function(cartesians, result) {
  367. //>>includeStart('debug', pragmas.debug);
  368. Check.Check.defined('cartesians', cartesians);
  369. //>>includeEnd('debug');
  370. if (!when.defined(result)) {
  371. result = [];
  372. }
  373. var count = 0;
  374. var length = cartesians.length;
  375. for ( var i = 0; i < length; i++) {
  376. var p = this.projectPointOntoPlane(cartesians[i], result[count]);
  377. if (when.defined(p)) {
  378. result[count] = p;
  379. count++;
  380. }
  381. }
  382. result.length = count;
  383. return result;
  384. };
  385. /**
  386. * Computes the projection of the provided 3D position onto the 2D plane, along the plane normal.
  387. *
  388. * @param {Cartesian3} cartesian The point to project.
  389. * @param {Cartesian2} [result] The object onto which to store the result.
  390. * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if none was provided.
  391. */
  392. EllipsoidTangentPlane.prototype.projectPointToNearestOnPlane = function(cartesian, result) {
  393. //>>includeStart('debug', pragmas.debug);
  394. Check.Check.defined('cartesian', cartesian);
  395. //>>includeEnd('debug');
  396. if (!when.defined(result)) {
  397. result = new Cartesian2.Cartesian2();
  398. }
  399. var ray = scratchProjectPointOntoPlaneRay;
  400. ray.origin = cartesian;
  401. Cartographic.Cartesian3.clone(this._plane.normal, ray.direction);
  402. var intersectionPoint = IntersectionTests.IntersectionTests.rayPlane(ray, this._plane, scratchProjectPointOntoPlaneCartesian3);
  403. if (!when.defined(intersectionPoint)) {
  404. Cartographic.Cartesian3.negate(ray.direction, ray.direction);
  405. intersectionPoint = IntersectionTests.IntersectionTests.rayPlane(ray, this._plane, scratchProjectPointOntoPlaneCartesian3);
  406. }
  407. var v = Cartographic.Cartesian3.subtract(intersectionPoint, this._origin, intersectionPoint);
  408. var x = Cartographic.Cartesian3.dot(this._xAxis, v);
  409. var y = Cartographic.Cartesian3.dot(this._yAxis, v);
  410. result.x = x;
  411. result.y = y;
  412. return result;
  413. };
  414. /**
  415. * Computes the projection of the provided 3D positions onto the 2D plane, along the plane normal.
  416. *
  417. * @see EllipsoidTangentPlane.projectPointToNearestOnPlane
  418. *
  419. * @param {Cartesian3[]} cartesians The array of points to project.
  420. * @param {Cartesian2[]} [result] The array of Cartesian2 instances onto which to store results.
  421. * @returns {Cartesian2[]} The modified result parameter or a new array of Cartesian2 instances if none was provided. This will have the same length as <code>cartesians</code>.
  422. */
  423. EllipsoidTangentPlane.prototype.projectPointsToNearestOnPlane = function(cartesians, result) {
  424. //>>includeStart('debug', pragmas.debug);
  425. Check.Check.defined('cartesians', cartesians);
  426. //>>includeEnd('debug');
  427. if (!when.defined(result)) {
  428. result = [];
  429. }
  430. var length = cartesians.length;
  431. result.length = length;
  432. for (var i = 0; i < length; i++) {
  433. result[i] = this.projectPointToNearestOnPlane(cartesians[i], result[i]);
  434. }
  435. return result;
  436. };
  437. var projectPointsOntoEllipsoidScratch = new Cartographic.Cartesian3();
  438. /**
  439. * Computes the projection of the provided 2D position onto the 3D ellipsoid.
  440. *
  441. * @param {Cartesian2} cartesian The points to project.
  442. * @param {Cartesian3} [result] The Cartesian3 instance to store result.
  443. * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if none was provided.
  444. */
  445. EllipsoidTangentPlane.prototype.projectPointOntoEllipsoid = function(cartesian, result) {
  446. //>>includeStart('debug', pragmas.debug);
  447. Check.Check.defined('cartesian', cartesian);
  448. //>>includeEnd('debug');
  449. if (!when.defined(result)) {
  450. result = new Cartographic.Cartesian3();
  451. }
  452. var ellipsoid = this._ellipsoid;
  453. var origin = this._origin;
  454. var xAxis = this._xAxis;
  455. var yAxis = this._yAxis;
  456. var tmp = projectPointsOntoEllipsoidScratch;
  457. Cartographic.Cartesian3.multiplyByScalar(xAxis, cartesian.x, tmp);
  458. result = Cartographic.Cartesian3.add(origin, tmp, result);
  459. Cartographic.Cartesian3.multiplyByScalar(yAxis, cartesian.y, tmp);
  460. Cartographic.Cartesian3.add(result, tmp, result);
  461. ellipsoid.scaleToGeocentricSurface(result, result);
  462. return result;
  463. };
  464. /**
  465. * Computes the projection of the provided 2D positions onto the 3D ellipsoid.
  466. *
  467. * @param {Cartesian2[]} cartesians The array of points to project.
  468. * @param {Cartesian3[]} [result] The array of Cartesian3 instances onto which to store results.
  469. * @returns {Cartesian3[]} The modified result parameter or a new array of Cartesian3 instances if none was provided.
  470. */
  471. EllipsoidTangentPlane.prototype.projectPointsOntoEllipsoid = function(cartesians, result) {
  472. //>>includeStart('debug', pragmas.debug);
  473. Check.Check.defined('cartesians', cartesians);
  474. //>>includeEnd('debug');
  475. var length = cartesians.length;
  476. if (!when.defined(result)) {
  477. result = new Array(length);
  478. } else {
  479. result.length = length;
  480. }
  481. for ( var i = 0; i < length; ++i) {
  482. result[i] = this.projectPointOntoEllipsoid(cartesians[i], result[i]);
  483. }
  484. return result;
  485. };
  486. exports.AxisAlignedBoundingBox = AxisAlignedBoundingBox;
  487. exports.EllipsoidTangentPlane = EllipsoidTangentPlane;
  488. });