convert-angle.js 362 B

12345678910111213141516171819
  1. /**
  2. * Convert given value's base into the parameter unitName
  3. *
  4. * @param {Double} value
  5. * @param {String} unitName
  6. * @return {Double}
  7. * @api private
  8. */
  9. module.exports = function convertAngle(value, unitName) {
  10. var factors = {
  11. "rad" : 1,
  12. "deg" : 180 / Math.PI,
  13. "turn": 0.5 / Math.PI,
  14. "grad": 200 / Math.PI
  15. }
  16. return value * factors[unitName];
  17. }