HeadingPitchRange.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import defaultValue from './defaultValue.js';
  2. import defined from './defined.js';
  3. /**
  4. * Defines a heading angle, pitch angle, and range in a local frame.
  5. * Heading is the rotation from the local north direction where a positive angle is increasing eastward.
  6. * Pitch is the rotation from the local xy-plane. Positive pitch angles are above the plane. Negative pitch
  7. * angles are below the plane. Range is the distance from the center of the frame.
  8. * @alias HeadingPitchRange
  9. * @constructor
  10. *
  11. * @param {Number} [heading=0.0] The heading angle in radians.
  12. * @param {Number} [pitch=0.0] The pitch angle in radians.
  13. * @param {Number} [range=0.0] The distance from the center in meters.
  14. */
  15. function HeadingPitchRange(heading, pitch, range) {
  16. /**
  17. * Heading is the rotation from the local north direction where a positive angle is increasing eastward.
  18. * @type {Number}
  19. */
  20. this.heading = defaultValue(heading, 0.0);
  21. /**
  22. * Pitch is the rotation from the local xy-plane. Positive pitch angles
  23. * are above the plane. Negative pitch angles are below the plane.
  24. * @type {Number}
  25. */
  26. this.pitch = defaultValue(pitch, 0.0);
  27. /**
  28. * Range is the distance from the center of the local frame.
  29. * @type {Number}
  30. */
  31. this.range = defaultValue(range, 0.0);
  32. }
  33. /**
  34. * Duplicates a HeadingPitchRange instance.
  35. *
  36. * @param {HeadingPitchRange} hpr The HeadingPitchRange to duplicate.
  37. * @param {HeadingPitchRange} [result] The object onto which to store the result.
  38. * @returns {HeadingPitchRange} The modified result parameter or a new HeadingPitchRange instance if one was not provided. (Returns undefined if hpr is undefined)
  39. */
  40. HeadingPitchRange.clone = function(hpr, result) {
  41. if (!defined(hpr)) {
  42. return undefined;
  43. }
  44. if (!defined(result)) {
  45. result = new HeadingPitchRange();
  46. }
  47. result.heading = hpr.heading;
  48. result.pitch = hpr.pitch;
  49. result.range = hpr.range;
  50. return result;
  51. };
  52. export default HeadingPitchRange;