Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2186 from royels/1567
issue-1567
- Loading branch information
Showing
7 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var utils = require('../utils') | ||
, nodes = require('../nodes') | ||
, convert = require('./convert-angle') | ||
, asin = require('./asin'); | ||
|
||
/** | ||
* Return the arccosine of the given `value`. | ||
* | ||
* @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).val; | ||
var m = Math.pow(10, 9); | ||
convertedValue = Math.round(convertedValue * m) / m; | ||
return new nodes.Unit(convertedValue, output); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var utils = require('../utils') | ||
, nodes = require('../nodes') | ||
, convert = require('./convert-angle'); | ||
|
||
/** | ||
* Return the arcsine of the given `value`. | ||
* | ||
* @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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var utils = require('../utils') | ||
, nodes = require('../nodes') | ||
, convert = require('./convert-angle'); | ||
|
||
/** | ||
* Return the arctangent of the given `value`. | ||
* | ||
* @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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
/** | ||
* 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, | ||
"deg" : 180 / Math.PI, | ||
"turn": 0.5 / Math.PI, | ||
"grad": 200 / Math.PI | ||
} | ||
return value * factors[unitName]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters