@fczbkk/angle v2.0.1
Angle
Simple JavaScript library for working with angles.
Documentation
Angle
Class representing an angle.
constructor
Create an angle.
Parameters
configObject$0Object (optional, default{})$0.directions_start(optional, defaultdefault_directions_start)$0.directions(optional, defaultdefault_directions)
directions_start
directions
toDirection
Converts angle in degrees to direction keyword.
Parameters
anglenumber
Examples
(new Angle()).toDirection(90); // --> 'top'Returns string
fromDirection
Converts direction keyword to angle in degrees. Returns null if direction keyword is not defined.
Parameters
directionstring
Examples
(new Angle()).fromDirection('top'); // --> 90Returns (number | null)
radToDeg
Convert angle from radians to degrees.
Parameters
anglenumber
Examples
Array.radToDeg(Math.PI); // --> 180Returns number
degToRad
Convert angle from degrees to radians.
Parameters
anglenumber
Examples
Array.radToDeg(180); // --> Math.PIReturns number
normalize
Converts angle in degrees into equal angle in range between 0 and 360.
Parameters
anglenumber
Examples
Array.normalize(450); // --> 90Returns number
Bug reports, feature requests and contact
If you found any bugs, if you have feature requests or any questions, please, either file an issue at GitHub or send me an e-mail at riki@fczbkk.com.
License
Angle is published under the MIT license.