This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/stylus/lib/functions/tan.js

29 lines
565 B
JavaScript
Raw Normal View History

2019-08-11 18:48:02 +00:00
var utils = require('../utils')
, nodes = require('../nodes');
/**
* Return the tangent of the given `angle`.
*
* @param {Unit} angle
* @return {Unit}
* @api public
*/
module.exports = function tan(angle) {
utils.assertType(angle, 'unit', 'angle');
var radians = angle.val;
if (angle.type === 'deg') {
radians *= Math.PI / 180;
}
var m = Math.pow(10, 9);
var sin = Math.round(Math.sin(radians) * m) / m
, cos = Math.round(Math.cos(radians) * m) / m
, tan = Math.round(m * sin / cos ) / m;
return new nodes.Unit(tan, '');
};