Skip to content

DegOperations.js

Travis CI User edited this page Sep 24, 2018 · 1 revision

Functions

rad(d)number

converts radians to degrees

deg(r)number

converts degrees to radians

sinDeg(a)number

calculates sines with value in degrees

cosDeg(a)number

calculates cosines with value in degrees

tanDeg(a)number

calculates tangent with value in degrees

atanDeg(x)number

calculates arctangent in degrees

ascent(p0, p1)number

calculates ascent of two two-dimentsional points in radians

ascentDeg(p0, p1)number

calculates ascent of two two-dimentsional points in degrees

simplifyRotation(val)number

Sometimes, it's inpractical when the angles are bigger than a half turn or smaller than -a half turn. This function aims to avoid this problem by 'normalizing' the value

rad(d) ⇒ number

converts radians to degrees

Kind: global function
Returns: number - number in radians

Param Type Description
d number number in degree

Example

DegOperations.rad(0) //is 0
  DegOperations.rad(90) === Math.PI/2 //is true
  DegOperations.rad(180) === Math.PI //is true

deg(r) ⇒ number

converts degrees to radians

Kind: global function
Returns: number - number in degree

Param Type Description
r number number in radians

Example

DegOperations.deg(0) //is 0
  DegOperations.deg(Math.PI) //is 180

sinDeg(a) ⇒ number

calculates sines with value in degrees

Kind: global function
Returns: number - sines value

Param Type Description
a number abscissa for the sines function in degrees

Example

DegOperations.sinDeg(0)  //is 0
  DegOperations.sinDeg(90) //is 1

cosDeg(a) ⇒ number

calculates cosines with value in degrees

Kind: global function
Returns: number - cosines value

Param Type Description
a number abscissa for the cosines function in degrees

Example

DegOperations.cosDeg(0)   //is 1
  DegOperations.cosDeg(90)  //is 0
  DegOperations.cosDeg(180) //is -1
  DegOperations.cosDeg(270) //is 0

tanDeg(a) ⇒ number

calculates tangent with value in degrees

Kind: global function
Returns: number - tangent value

Param Type Description
a number abscissa for the tangent function in degrees

Example

DegOperations.tanDeg(0)  //is 0
  DegOperations.tanDeg(90) //is 16331239353195370

atanDeg(x) ⇒ number

calculates arctangent in degrees

Kind: global function
Returns: number - arctangent value in degrees

Param Type Description
x number abscissa for the arctangent function

Example

DegOperations.atanDeg(0) //is 0
  DegOperations.atanDeg(16331239353195370) //is 90

ascent(p0, p1) ⇒ number

calculates ascent of two two-dimentsional points in radians

Kind: global function
Returns: number - ascent in rad

Param Type Description
p0 Array.<number> first of two two-dimensional points
p1 Array.<number> second of two two-dimensional points

Example

const p0 = [0, 0],
      p1 = [1, 1];
  DegOperations.ascent(p0, p1) === Math.PI/4 //is true

Example

const p0 = [0, 0],
      p1 = [1, 0];
  DegOperations.ascent(p0, p1) //is 0

ascentDeg(p0, p1) ⇒ number

calculates ascent of two two-dimentsional points in degrees

Kind: global function
Returns: number - ascent in deg

Param Type Description
p0 Array.<number> first of two two-dimensional points
p1 Array.<number> second of two two-dimensional points

Example

const p0 = [0, 0],
      p1 = [1, 1];
  DegOperations.ascentDeg(p0, p1) //is 45

Example

const p0 = [0, 0],
      p1 = [1, 0];
  DegOperations.ascentDeg(p0, p1) //is 0

simplifyRotation(val) ⇒ number

Sometimes, it's inpractical when the angles are bigger than a half turn or smaller than -a half turn. This function aims to avoid this problem by 'normalizing' the value

Kind: global function
Returns: number - angle between -πrad and πrad

Param Type Description
val number initial angle in rad that might be too big or small

Example

DegOperations.simplifyRotation(0) //is 0
  DegOperations.simplifyRotation(2 * Math.PI) //is 0
  DegOperations.simplifyRotation(10 * Math.PI + 1) //is 1