-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gravity_H.m
43 lines (33 loc) · 913 Bytes
/
Gravity_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
function [sphere_moving_x, sphere_moving_y, sphere_moving_z] = Gravity_H(v0, theta, 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;
vx = v0*cos(theta);
vz = v0*sin(theta);
x = 0;
z = 0;
vx = v0*cos(theta);
vz = vz - grav*dt;
x = x + vx*dt;
z = z + vz*dt;
sphere_moving_x = x;
sphere_moving_z = z;
while true
vx = v0*cos(theta);
vz = vz - grav*dt;
x = x + vx*dt;
z = z + vz*dt;
if (z < 0)
break
end
sphere_moving_x = [sphere_moving_x; x];
sphere_moving_z = [sphere_moving_z; z];
end
sphere_moving_y = zeros(length(sphere_moving_x), 1);
Plot_Trajectory_H(sphere_moving_x, sphere_moving_y, sphere_moving_z)
end