source: trip-planner-front/node_modules/stylus/lib/functions/tan.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 593 bytes
RevLine 
[6a3a178]1var utils = require('../utils')
2 , nodes = require('../nodes');
3
4/**
5 * Return the tangent of the given `angle`.
6 *
7 * @param {Unit} angle
8 * @return {Unit}
9 * @api public
10 */
11
12function tan(angle) {
13 utils.assertType(angle, 'unit', 'angle');
14
15 var radians = angle.val;
16
17 if (angle.type === 'deg') {
18 radians *= Math.PI / 180;
19 }
20
21 var m = Math.pow(10, 9);
22
23 var sin = Math.round(Math.sin(radians) * m) / m
24 , cos = Math.round(Math.cos(radians) * m) / m
25 , tan = Math.round(m * sin / cos ) / m;
26
27 return new nodes.Unit(tan, '');
28}
29tan.params = ['angle'];
30module.exports = tan;
Note: See TracBrowser for help on using the repository browser.