All files / engine/Source/Core HeadingPitchRange.js

91.66% Statements 11/12
90% Branches 9/10
100% Functions 2/2
91.66% Lines 11/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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