-
Notifications
You must be signed in to change notification settings - Fork 0
/
DegMath.js
99 lines (84 loc) · 1.78 KB
/
DegMath.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* ----< Copyright Block >----
*
* Prayer Times Calculator
* DegMath.js
* Copyright (C) 2015
* Mohsen Izadi <[email protected]>
*
* Based On:
* PrayTimes.js (v2.3)
* Copyright (C) 2007-2011 PrayTimes.org
* Hamid Zarrabi-Zadeh
*
* License: GNU LGPL v3.0
*
* TERMS OF USE:
* Permission is granted to use this code, with or
* without modification, in any website or application
* provided that credit is given to the original work
* with a link back to PrayTimes.org.
*
* This program is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY.
*
* PLEASE DO NOT REMOVE THIS COPYRIGHT BLOCK.
*
*/
var libpraytimes = libpraytimes || {};
libpraytimes.DegMath = function() {
var dtr = function(d) {
return (d * Math.PI) / 180;
};
var rtd = function(r) {
return (r * 180) / Math.PI;
};
var sin = function(d) {
return Math.sin(dtr(d));
};
var cos = function(d) {
return Math.cos(dtr(d));
};
var tan = function(d) {
return Math.tan(dtr(d));
};
var arcsin = function(d) {
return rtd(Math.asin(d));
};
var arccos = function(d) {
return rtd(Math.acos(d));
};
var arctan = function(d) {
return rtd(Math.atan(d));
};
var arccot = function(x) {
return rtd(Math.atan(1 / x));
};
var arctan2 = function(y, x) {
return rtd(Math.atan2(y, x));
};
var fix = function(a, b) {
a = a - b * (Math.floor(a / b));
return (a < 0) ? a + b : a;
};
var fixAngle = function(a) {
return fix(a, 360);
};
var fixHour = function(a) {
return fix(a, 24 );
};
return {
dtr: dtr,
rtd: rtd,
sin: sin,
cos: cos,
tan: tan,
arcsin: arcsin,
arccos: arccos,
arctan: arctan,
arccot: arccot,
arctan2: arctan2,
fix: fix,
fixAngle: fixAngle,
fixHour: fixHour,
};
}();