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
pub mod uniconv {
//! This is used to convert units of various measurements
//!
//! All methods use the same parameters `(unit1: f32 )->f32`
//!
//! - unit1 represents the unit to be converted
//! - represents the converted unit
// Ex. function
// pub fn (unit1: f32 ) -> f32{}
pub mod temperature {
//! This is used to convert temperatures
/// Fahrenheit to Celsius degrees
pub fn fahr_to_cels(unit1: f32) -> f32 {
(unit1 - 32.0) * (5.0 / 9.0)
}
/// Fahrenheit to Kelvin degrees
pub fn fahr_to_kelv(unit1: f32) -> f32 {
(5.0 / 9.0) * (unit1 - 32.0) + 273.0
}
/// Celsius to Fahrenheit degrees
pub fn cels_to_fahr(unit1: f32) -> f32 {
(unit1 * 9.0 / 5.0) + 32.0
}
/// Celsius to Kelvin degrees
pub fn cels_to_kelv(unit1: f32) -> f32 {
unit1 + 273.0
}
/// Kelvin to Fahrenheit degrees
pub fn kelv_to_fahr(unit1: f32) -> f32 {
(9.0 / 5.0) * (unit1 - 273.0) + 32.0
}
/// Kelvin to Celsius degrees
pub fn kelv_to_cels(unit1: f32) -> f32 {
unit1 - 273.0
}
}
pub mod speed {
//! This is used to convert speeds
/// Metres per Second to Kilometre per Hour
pub fn mps_to_kph(unit1: f32) -> f32 {
unit1 * 3.6
}
/// Kilometre per Hour to Metres per Second
pub fn kph_to_mps(unit1: f32) -> f32 {
unit1 / 3.6
}
/// Metres per Second to Knots
pub fn mps_to_knots(unit1: f32) -> f32 {
unit1 * 1.944
}
/// Kilometre per Hour to Knots
pub fn kph_to_knots(unit1: f32) -> f32 {
unit1 / 1.852
}
}
pub mod length {
//! This is used to convert lengths
//!
//! **Only metres will be used for imperial unit conversions!**
/// Metres to Inches
pub fn m_to_inch(unit1: f32) -> f32 {
unit1 * 39.37
}
/// Metres to Feet
pub fn m_to_foot(unit1: f32) -> f32 {
unit1 * 3.281
}
/// Metres to Yards
pub fn m_to_yard(unit1: f32) -> f32 {
unit1 * 1.094
}
/// Metres to Miles
pub fn m_to_mile(unit1: f32) -> f32 {
unit1 / 1609.0
}
/// Inches to Metres
pub fn inch_to_m(unit1: f32) -> f32 {
unit1 / 39.37
}
/// Feet to Metres
pub fn foot_to_m(unit1: f32) -> f32 {
unit1 / 3.281
}
/// Yards to Metres
pub fn yard_to_m(unit1: f32) -> f32 {
unit1 / 1.094
}
/// Miles to Metres
pub fn mile_to_m(unit1: f32) -> f32 {
unit1 * 1609.0
}
/// Milimetres to Metres
pub fn mm_to_m(unit1: f32) -> f32 {
unit1 / 1000.0
}
/// Centimetres to Metres
pub fn cm_to_m(unit1: f32) -> f32 {
unit1 / 100.0
}
/// Kilometres to Metres
pub fn km_to_m(unit1: f32) -> f32 {
unit1 * 1000.0
}
}
}