acos.js 609 B

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