-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspeed.js
114 lines (93 loc) · 2.85 KB
/
speed.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
(function(angular){ 'use strict';
angular.module('conversions.speed', [])
.factory('conversionsSpeed', ['$log', function($log){
return {
//=========
// !Errors
//=========
amtTypeError: function(amt){
$log.error(amt+' is not a number and cannot be converted');
return NaN;
},
//====================
// !Speed Conversions
//====================
milesPerhourToFeetPersec: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 1.46667;
},
milesPerhourToMetersPersec: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 0.44704;
},
milesPerhourToKmPerhour: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 1.60934;
},
milesPerhourToKnot: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 0.868976;
},
feetPersecToMilesPerhour: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 0.681818;
},
feetPersecToMetersPersec: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 0.3048;
},
feetPersecToKmPerhour: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 1.09728;
},
feetPersecToKnot: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 0.592484;
},
metersPersecToMilesPerhour: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 2.23694;
},
metersPersecToFeetPersec: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 3.28084;
},
metersPersecToKmPerhour: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 3.6;
},
metersPersecToKnot: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 1.94384;
},
kmPerhourToMilesPerhour: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 0.621371;
},
kmPerhourToFeetPersec: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 0.911344;
},
kmPerhourToMetersPersec: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 0.277778;
},
kmPerhourToKnot: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 0.539957;
},
knotToFeetPersec: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 1.68781;
},
knotToMetersPersec: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 0.514444;
},
knotToKmPerhour: function(amt){
if(isNaN(amt)) return this.amtTypeError(amt);
return amt * 1.852;
}
};
}]);
})(window.angular);