-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAirPressureValue.m
53 lines (49 loc) · 1 KB
/
AirPressureValue.m
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
//
// AirPressureValue.m
// Barometer
//
// Created by Montana Burr on 10/23/14.
// Copyright (c) 2014 Montana. All rights reserved.
//
#import "AirPressureValue.h"
@implementation AirPressureValue
{
float kiloPascalsFloat;
float mmHg;
float psi;
float inHg;
}
-(id)initWithkiloPascals:(float)kiloPascals
{
self = [super init];
if (self) {
kiloPascalsFloat = kiloPascals;
mmHg = kiloPascalsFloat * 7.50061683;
psi = kiloPascalsFloat * 0.145037738;
inHg = kiloPascalsFloat * 0.295301;
};
return self;
}
-(float)kiloPascals
{
return kiloPascalsFloat;
}
-(float)mmHg
{
return mmHg;
}
-(float)psi
{
return psi;
}
-(float)inHg
{
return inHg;
}
-(AirPressureValue *)convertToSeaLevelFromAltitude:(float)altitude
{
float seaLevelPressure = kiloPascalsFloat / powf(1 - (0.0000225577 * altitude), 5.25588);
AirPressureValue *seaLevelValue = [[AirPressureValue alloc] initWithkiloPascals:seaLevelPressure];
return seaLevelValue;
}
@end