* Computes the normalized form of the supplied Cartesian. * * @param {Cartesian2} cartesian The Cartesian to be normalized. * @param {Cartesian2} result The object onto which to store the result. * @returns {Cartesian2} The modified result parameter.
(cartesian, result)
| 355 | * @returns {Cartesian2} The modified result parameter. |
| 356 | */ |
| 357 | static normalize(cartesian, result) { |
| 358 | //>>includeStart('debug', pragmas.debug); |
| 359 | Check.typeOf.object("cartesian", cartesian); |
| 360 | Check.typeOf.object("result", result); |
| 361 | //>>includeEnd('debug'); |
| 362 | |
| 363 | const magnitude = Cartesian2.magnitude(cartesian); |
| 364 | |
| 365 | result.x = cartesian.x / magnitude; |
| 366 | result.y = cartesian.y / magnitude; |
| 367 | |
| 368 | //>>includeStart('debug', pragmas.debug); |
| 369 | if (isNaN(result.x) || isNaN(result.y)) { |
| 370 | throw new DeveloperError("normalized result is not a number"); |
| 371 | } |
| 372 | //>>includeEnd('debug'); |
| 373 | |
| 374 | return result; |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * Computes the dot (scalar) product of two Cartesians. |
no test coverage detected