atan2.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createAtan2 = void 0;
  6. var _factory = require("../../utils/factory.js");
  7. var _matAlgo02xDS = require("../../type/matrix/utils/matAlgo02xDS0.js");
  8. var _matAlgo03xDSf = require("../../type/matrix/utils/matAlgo03xDSf.js");
  9. var _matAlgo09xS0Sf = require("../../type/matrix/utils/matAlgo09xS0Sf.js");
  10. var _matAlgo11xS0s = require("../../type/matrix/utils/matAlgo11xS0s.js");
  11. var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
  12. var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
  13. var name = 'atan2';
  14. var dependencies = ['typed', 'matrix', 'equalScalar', 'BigNumber', 'DenseMatrix', 'concat'];
  15. var createAtan2 = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
  16. var typed = _ref.typed,
  17. matrix = _ref.matrix,
  18. equalScalar = _ref.equalScalar,
  19. BigNumber = _ref.BigNumber,
  20. DenseMatrix = _ref.DenseMatrix,
  21. concat = _ref.concat;
  22. var matAlgo02xDS0 = (0, _matAlgo02xDS.createMatAlgo02xDS0)({
  23. typed: typed,
  24. equalScalar: equalScalar
  25. });
  26. var matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
  27. typed: typed
  28. });
  29. var matAlgo09xS0Sf = (0, _matAlgo09xS0Sf.createMatAlgo09xS0Sf)({
  30. typed: typed,
  31. equalScalar: equalScalar
  32. });
  33. var matAlgo11xS0s = (0, _matAlgo11xS0s.createMatAlgo11xS0s)({
  34. typed: typed,
  35. equalScalar: equalScalar
  36. });
  37. var matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
  38. typed: typed,
  39. DenseMatrix: DenseMatrix
  40. });
  41. var matrixAlgorithmSuite = (0, _matrixAlgorithmSuite.createMatrixAlgorithmSuite)({
  42. typed: typed,
  43. matrix: matrix,
  44. concat: concat
  45. });
  46. /**
  47. * Calculate the inverse tangent function with two arguments, y/x.
  48. * By providing two arguments, the right quadrant of the computed angle can be
  49. * determined.
  50. *
  51. * For matrices, the function is evaluated element wise.
  52. *
  53. * Syntax:
  54. *
  55. * math.atan2(y, x)
  56. *
  57. * Examples:
  58. *
  59. * math.atan2(2, 2) / math.pi // returns number 0.25
  60. *
  61. * const angle = math.unit(60, 'deg') // returns Unit 60 deg
  62. * const x = math.cos(angle)
  63. * const y = math.sin(angle)
  64. *
  65. * math.atan(2) // returns number 1.1071487177940904
  66. *
  67. * See also:
  68. *
  69. * tan, atan, sin, cos
  70. *
  71. * @param {number | Array | Matrix} y Second dimension
  72. * @param {number | Array | Matrix} x First dimension
  73. * @return {number | Array | Matrix} Four-quadrant inverse tangent
  74. */
  75. return typed(name, {
  76. 'number, number': Math.atan2,
  77. // Complex numbers doesn't seem to have a reasonable implementation of
  78. // atan2(). Even Matlab removed the support, after they only calculated
  79. // the atan only on base of the real part of the numbers and ignored
  80. // the imaginary.
  81. 'BigNumber, BigNumber': function BigNumberBigNumber(y, x) {
  82. return BigNumber.atan2(y, x);
  83. }
  84. }, matrixAlgorithmSuite({
  85. scalar: 'number | BigNumber',
  86. SS: matAlgo09xS0Sf,
  87. DS: matAlgo03xDSf,
  88. SD: matAlgo02xDS0,
  89. Ss: matAlgo11xS0s,
  90. sS: matAlgo12xSfs
  91. }));
  92. });
  93. exports.createAtan2 = createAtan2;