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
pub trait BeamProperties {
fn area(&self) -> f32;
fn moment_of_inertia(&self) -> f32;
fn section_modulus(&self) -> f32;
fn radius_of_gyration(&self) -> f32;
}
#[derive(Debug)]
pub struct RectangularBeam {
pub d: f32,
pub b: f32,
}
impl BeamProperties for RectangularBeam {
fn area(&self) -> f32 {
self.d * self.b
}
fn moment_of_inertia(&self) -> f32 {
self.b * self.d.powf(3.0) / 12.0
}
fn section_modulus(&self) -> f32 {
self.b * self.d.powf(2.0) / 6.0
}
fn radius_of_gyration(&self) -> f32 {
(self.moment_of_inertia() / self.area()).powf(0.5)
}
}
#[derive(Debug)]
pub struct TriangularBeam {
pub d: f32,
pub b: f32,
}
impl BeamProperties for TriangularBeam {
fn area(&self) -> f32 {
self.d * self.b / 2.0
}
fn moment_of_inertia(&self) -> f32 {
self.b * self.d.powf(3.0) / 36.0
}
fn section_modulus(&self) -> f32 {
self.b * self.d.powf(2.0) / 24.0
}
fn radius_of_gyration(&self) -> f32 {
(self.moment_of_inertia() / self.area()).powf(0.5)
}
}
#[derive(Debug)]
pub enum BeamType {
Rectangular(RectangularBeam),
Triangular(TriangularBeam),
}
#[derive(Debug)]
pub struct Beam {
pub section: BeamType
}