HeadingPitchRange.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. * @default 0.0
  20. */
  21. this.heading = defaultValue(heading, 0.0);
  22. /**
  23. * Pitch is the rotation from the local xy-plane. Positive pitch angles
  24. * are above the plane. Negative pitch angles are below the plane.
  25. * @type {Number}
  26. * @default 0.0
  27. */
  28. this.pitch = defaultValue(pitch, 0.0);
  29. /**
  30. * Range is the distance from the center of the local frame.
  31. * @type {Number}
  32. * @default 0.0
  33. */
  34. this.range = defaultValue(range, 0.0);
  35. }
  36. /**
  37. * Duplicates a HeadingPitchRange instance.
  38. *
  39. * @param {HeadingPitchRange} hpr The HeadingPitchRange to duplicate.
  40. * @param {HeadingPitchRange} [result] The object onto which to store the result.
  41. * @returns {HeadingPitchRange} The modified result parameter or a new HeadingPitchRange instance if one was not provided. (Returns undefined if hpr is undefined)
  42. */
  43. HeadingPitchRange.clone = function (hpr, result) {
  44. if (!defined(hpr)) {
  45. return undefined;
  46. }
  47. if (!defined(result)) {
  48. result = new HeadingPitchRange();
  49. }
  50. result.heading = hpr.heading;
  51. result.pitch = hpr.pitch;
  52. result.range = hpr.range;
  53. return result;
  54. };
  55. export default HeadingPitchRange;