@fczbkk/angle

2.0.1 • Public • Published

Angle

Simple JavaScript library for working with angles.

Documentation

Angle

Class representing an angle.

constructor

Create an angle.

Parameters

  • config Object
    • config.directions_start number Value with which first direction keyword will be associated.
    • config.directions Array<string> List of direction keywords.
  • $0 Object (optional, default {})
    • $0.directions_start (optional, default default_directions_start)
    • $0.directions (optional, default default_directions)

directions_start

directions

toDirection

Converts angle in degrees to direction keyword.

Parameters

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

Examples

(new Angle()).fromDirection('top'); // --> 90

Returns (number | null)

radToDeg

Convert angle from radians to degrees.

Parameters

Examples

Array.radToDeg(Math.PI); // --> 180

Returns number

degToRad

Convert angle from degrees to radians.

Parameters

Examples

Array.radToDeg(180); // --> Math.PI

Returns number

normalize

Converts angle in degrees into equal angle in range between 0 and 360.

Parameters

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 riki@fczbkk.com.

License

Angle is published under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i @fczbkk/angle

Weekly Downloads

0

Version

2.0.1

License

MIT

Last publish

Collaborators

  • fczbkk