rad2deg
Converts radians to degrees.
Installation
$ npm install compute-rad2deg
For use in the browser, use browserify.
Usage
To use the module,
var rad2deg = ;
rad2deg( x )
Converts radians to degrees. x
may be either a numeric array
or a single numeric value.
// Single value:var deg = ;// returns 90// Array of values:var rads = 0 MathPI/4 MathPI/2 3*MathPI/4 MathPI ;;// returns [ 0, 45, 90, 135, 180 ]
Examples
var rad2deg = ;// Simulate some data...var data = 100 ;var twopi = 2*MathPI;for var i = 0; i < datalength; i++data i = Math*twopi;;console;
To run the example code from the top-level application directory,
$ node ./examples/index.js
Notes
- If provided an input
array
, thearray
is mutated. If mutation is undesired,
var data = 0 45 90 135 180copy = data;;
-
If provided an empty
array
, the function returnsnull
. -
Beware of floating point errors.
var deg = ;// returns 29.999999999999996 instead of 30
Tests
Unit
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
License
Copyright
Copyright © 2014. Athan Reines.