atan.js 580 B

123456789101112131415161718192021
  1. var utils = require('../utils')
  2. , nodes = require('../nodes')
  3. , convert = require('./convert-angle');
  4. /**
  5. * Return the arctangent of the given `value`.
  6. *
  7. * @param {Double} trigValue
  8. * @param {Unit} output
  9. * @return {Unit}
  10. * @api public
  11. */
  12. module.exports = function atan(trigValue, output) {
  13. var output = typeof output !== 'undefined' ? output : 'deg';
  14. var value = Math.atan(trigValue) ;
  15. var m = Math.pow(10, 9);
  16. var convertedValue = convert(value, output);
  17. convertedValue = Math.round(convertedValue * m) / m;
  18. return new nodes.Unit(convertedValue, output);
  19. };