-
Notifications
You must be signed in to change notification settings - Fork 2
/
flight.m
60 lines (43 loc) · 1.42 KB
/
flight.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
function flight()
%UNTITLED5 Summary of this function goes here
% Detailed explanation goes here
global dt;
global x % current x-coordinate of ball
global y % current y-coordinate of ball
global x1 % new x-coordinate of ball
global y1 % new y-coordinate of ball
global ang %current angle of ball
global ang1 % new angle of ball
global vx % vx is current x-velocity of ball, initial value 1
global vy % vy is current y-velocit of ball, initial value 1
global vx1 % vx is current x-velocity of ball, initial value 1
global vy1 % vy is current y-velocit of ball, initial value 1
global w %current angular velocity
global w1 %new angular velocity
global motion_type;
disp('flight');
g=9.81; % gravity
%input parameters
% x->current x-coordinate of ball
% y->current y-coordinate of ball
% vx ->current x-velocity of ball
% vy ->current y-velocity of ball
%output parameters
% x1->updated x-coordinate of ball
% y1->updated y-coordinate of ball
% vx1->updated x-velocity of ball
% vy1->updated y-velocity of ball
ay= -g; % y-acceleration
ax= 0; % x-acceleration
dx = vx*dt; %small change in x
dy = vy*dt; %small change in y
dtheta = w*dt;
x1 = x+dx;
y1 = y+dy;
ang1 = ang + dtheta;
dvx = ax *dt; %small change in vx
dvy = ay *dt; %small change in vy
vy1 = vy + dvy;
vx1 = vx + dvx;
w1=w;
end