-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lift_H.m
66 lines (55 loc) · 1.6 KB
/
Lift_H.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
54
55
56
57
58
59
60
61
62
63
64
65
66
function [sphere_moving_x, sphere_moving_y, sphere_moving_z] = Lift_H(v0, theta, wx, wy, wz, phi, dt)
rho = 1.225;
grav =9.81;
mass = 0.042672;
diameter = 0.042672;
Area = pi*diameter^2/4;
Cd = 0.2;
Cl = 0.2;
theta = pi * theta / 180;
phi = pi * phi / 180;
omega = (wx^2 + wy^2 + wz^2);
if omega ~= 0
tx = wx/omega;
ty = wy/omega;
tz = wz/omega;
else
tx = 0;
ty = 0;
tz = 0;
end
vx = v0*cos(theta)*cos(phi);
vy = -(v0*cos(theta)*sin(phi));
vz = v0*sin(theta);
x = 0;
y = 0;
z = 0;
speed = sqrt(vx^2 + vy^2 + vz^2);
Q = rho*speed^2*Area/2;
vx = vx + (Q*Cl*(ty*vz-tz*vy)/speed)*dt/mass;
vy = vy + (Q*Cl*(tx*vy-ty*vx)/speed)*dt/mass;
vz = vz + (Q*Cl*(tz*vx-tx*vz)/speed)*dt/mass - grav*dt;
x = x + vx*dt;
y = y + vy*dt;
z = z + vz*dt;
sphere_moving_x = x;
sphere_moving_y = y;
sphere_moving_z = z;
while true
speed = sqrt(vx^2 + vy^2 + vz^2);
Q = rho*speed^2*Area/2;
vx = vx + (Q*Cl*(ty*vz-tz*vy)/speed)*dt/mass;
vy = vy + (Q*Cl*(tx*vy-ty*vx)/speed)*dt/mass;
vz = vz + (Q*Cl*(tz*vx-tx*vz)/speed)*dt/mass - grav*dt;
x = x + vx*dt;
y = y + vy*dt;
z = z + vz*dt;
if z < 0
break
end
sphere_moving_x = [sphere_moving_x; x];
sphere_moving_y = [sphere_moving_y; y];
sphere_moving_z = [sphere_moving_z; z];
end
Plot_Trajectory_H(sphere_moving_x, sphere_moving_y, sphere_moving_z)
end