summaryrefslogtreecommitdiff
path: root/ShedCalc/ParamModel.swift
blob: 0302019e687413b5024c05065bd02e8d48a45eb8 (plain) (blame)
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
//
//  ParamModel.swift
//  ShedCalc
//
//  Created by Jacky Jack on 01/08/2026.
//
import Combine
import SwiftUI
import Observation

@Observable
class ParamModel {
    var width: Double = 3.0
    var height: Double = 1.0
    var length: Double = 1.0
    var beamSpace: Double = 0.6
    var OSBSheetPrice: Double = 1.0
    var timberBeamPrice: Double = 1.0
    var timberLengthSize: Double = 2.4
    var feltPrice: Double = 1.0
    var feltWidth: Double = 1.0
    var feltLength: Double = 10
    var claddingPrice: Double = 1.0
    var claddingLength: Double = 2.4
    var claddingWidth: Double = 0.1
    var claddingOverlap: Double = 0.01
    var wrapPrice: Double = 1.0
    var wrapWidth: Double = 1.0
    var wrapLength: Double = 10
    
    func floorArea() -> Double {
        return width*length
    }
    
    func roofArea() -> Double {
        return width*length
    }
    
    func dimensions() -> SIMD3<Double> {
        return [width,length,height]
    }
    
    func widthBeamNum() -> Int {
        return Int(width/beamSpace) + 1
    }
    
    func lengthBeamNum() -> Int {
        return Int(length/beamSpace) + 1
    }
    
    func setBeamSpace(_ bs: Double) {
        self.beamSpace = bs
    }
    
    func totalWallBeams() -> Int {
        return 2 * (widthBeamNum() + lengthBeamNum())
    }
    
    func totalWallBeamLength() -> Double {
        return Double(totalWallBeams()) * self.height
    }
    
    func totalJoistBeamLength() -> Double {
        return Double(widthBeamNum())*beamSpace
    }
    
    func totalWallArea() -> Double {
        return  (self.width * self.height)*2 + (self.length * self.height)*2
    }
}