@fczbkk/angle
v2.0.1
Published
Simple JavaScript library for working with angles.
Downloads
3
Readme
Angle
Simple JavaScript library for working with angles.
Documentation
Angle
Class representing an angle.
constructor
Create an angle.
Parameters
config
Object$0
Object (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
angle
number
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
direction
string
Examples
(new Angle()).fromDirection('top'); // --> 90
Returns (number | null)
radToDeg
Convert angle from radians to degrees.
Parameters
angle
number
Examples
Array.radToDeg(Math.PI); // --> 180
Returns number
degToRad
Convert angle from degrees to radians.
Parameters
angle
number
Examples
Array.radToDeg(180); // --> Math.PI
Returns number
normalize
Converts angle in degrees into equal angle in range between 0 and 360.
Parameters
angle
number
Examples
Array.normalize(450); // --> 90
Returns 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 [email protected].
License
Angle is published under the MIT license.