Skip to content

Commit

Permalink
Changed the exponent function for rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
royels committed May 20, 2016
1 parent 83c410b commit 21d0cc8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/functions/acos.js
Expand Up @@ -4,15 +4,17 @@ var utils = require('../utils')
, asin = require('./asin');

/**
* Return the tangent of the given `angle`.
* Return the arccosine of the given `value`.
*
* @param {Unit} angle
* @param {Double} trigValue
* @param {Unit} output
* @return {Unit}
* @api public
*/

module.exports = function acos(trigValue, output) {
var output = typeof output !== 'undefined' ? output : 'deg';
var convertedValue = convert(Math.PI / 2, output) - asin(trigValue, output);
var convertedValue = convert(Math.PI / 2, output) - asin(trigValue, output).val;
var m = Math.pow(10, 9);
convertedValue = Math.round(convertedValue * m) / m;
return new nodes.Unit(convertedValue, output);
};
7 changes: 5 additions & 2 deletions lib/functions/asin.js
Expand Up @@ -3,16 +3,19 @@ var utils = require('../utils')
, convert = require('./convert-angle');

/**
* Return the tangent of the given `angle`.
* Return the arcsine of the given `value`.
*
* @param {Unit} angle
* @param {Double} trigValue
* @param {Unit} output
* @return {Unit}
* @api public
*/

module.exports = function atan(trigValue, output) {
var output = typeof output !== 'undefined' ? output : 'deg';
var m = Math.pow(10, 9);
var value = Math.asin(trigValue) ;
var convertedValue = convert(value, output);
convertedValue = Math.round(convertedValue * m) / m;
return new nodes.Unit(convertedValue, output);
};
7 changes: 5 additions & 2 deletions lib/functions/atan.js
Expand Up @@ -3,16 +3,19 @@ var utils = require('../utils')
, convert = require('./convert-angle');

/**
* Return the tangent of the given `angle`.
* Return the arctangent of the given `value`.
*
* @param {Unit} angle
* @param {Double} trigValue
* @param {Unit} output
* @return {Unit}
* @api public
*/

module.exports = function atan(trigValue, output) {
var output = typeof output !== 'undefined' ? output : 'deg';
var value = Math.atan(trigValue) ;
var m = Math.pow(10, 9);
var convertedValue = convert(value, output);
convertedValue = Math.round(convertedValue * m) / m;
return new nodes.Unit(convertedValue, output);
};
10 changes: 10 additions & 0 deletions lib/functions/convert-angle.js
@@ -1,3 +1,13 @@

/**
* Convert given value's base into the parameter unitName
*
* @param {Double} value
* @param {String} unitName
* @return {Double}
* @api private
*/

module.exports = function convertAngle(value, unitName) {
var factors = {
"rad" : 1,
Expand Down
6 changes: 6 additions & 0 deletions test/cases/bifs.math.css
Expand Up @@ -70,3 +70,9 @@
.math_atan {
test1: 45deg;
}
.math_asin {
test1: 44.999999985deg;
}
.math_acos {
test1: 45.000000015deg;
}
6 changes: 6 additions & 0 deletions test/cases/bifs.math.styl
Expand Up @@ -65,3 +65,9 @@

.math_atan
test1: atan(tan(45deg))

.math_asin
test1: asin(sin(45deg))

.math_acos
test1: acos(cos(45deg))

0 comments on commit 21d0cc8

Please sign in to comment.