-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbalisticmisisle_1.0.0
104 lines (83 loc) · 2.98 KB
/
balisticmisisle_1.0.0
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
Dim m, d, u, wing_s, cl, cd, theta_launch As Double ' Input_Param:missile_data as mass, nozzle diameter, jet_vel, wing_cl. wing_cd, launch_angle.
Dim t, missile_x, missile_y, velo, theta_wind As Double ' Calc_Param: time, x, y, v, windAngle, buffer.
Dim resolution_t, selfDistrunct As Double ' Calc_setting_param : how resolute calcuration of Integral
' now v0 is 0
Function getThrot(d, u, m, resolution_t)
Dim throt As Double
throt = d * u * m * resolution_t
getThrot = throt
End Function
Function getLift(velo, cl, wing_s)
lo = 1.293
Dim lift As Double
lift = ((v ^ 2) * wing_s * cl) / 2
getLift = lift
End Function
Function getDrag(velo, cd, wing_s)
lo = 1.293
Dim drag As Double
drag = ((v ^ 2) * wing_s * cd) / 2
getDrag = drag
End Function
Function getGrav(m, g)
Dim grav As Double
g = 9.8
grav = m * g
getGrav = grav
End Function
Function getWindAngle(m, wing_s, cl, theta_wind, velo) 'there, a = tan(a) =sin(a)
Dim delta_theta As Double
delta_theta = getLift(velo, cl, wing_s) - (getGrav(m, g)) * Cos((Pi / 180) * theta_wind)
theta_wind = theta_wind + delta_theta
getWindAngle = theta_wind
End Function
Function getVelo(m, d, u, wing_s, cl, cd, theta_launch)
Dim delta_velo As Double
m = 2 ` should be a garbage of test code, no need
delta_velo = (getThrot(d, u, m, resolution_t) - getDrag(velo, cd, wing_s)) / m
velo = velo + delta_velo
getVelo = velo
End Function
Function getxPos()
Dim delta_x As Double
delta_x = (getVelo(m, d, u, wing_s, cl, cd, theta_wind)) * Cos((Pi / 180) * getWindAngle(m, wing_s, cl, theta_wind, velo)) * resolution_t
missile_x = missile_x + delta_x
getxPos = delta_x
End Function
Function getyPos()
Dim delta_y As Double
delta_y = (getVelo(m, d, u, wing_s, cl, cd, theta_wind)) * Sin((Pi / 180) * getWindAngle(m, wing_s, cl, theta_wind, velo)) * resolution_t
missile_y = missile_y + delta_y
getyPos = deltay
End Function
Function ifTerm(y)
Dim impact As Boolean
impact = False
If y < 0 Then
impact = True
End If
If t > selfDistrunct Then
impact = True
End If
ifTerm = impact
End Function
Sub balistic_missile()
m = Cells(2, 2)
d = Cells(2, 3)
u = Cells(2, 4)
wing_s = Cells(2, 5)
cl = Cells(2, 6)
cd = Cells(2, 7)
theta_launch = Cells(2, 8)
resolution_t = Cells(2, 9)
Do
x = getxPos()
y = getyPos()
t = t + resolution_t
Loop Until ifTerm(y) = True
Cells(3, 2) = missile_x
Cells(3, 3) = missile_y
Cells(3, 4) = velo
Cells(3, 5) = theta_wind
missile_x = missile_y = velo = theta_wind = 0
End Sub