-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.m
71 lines (42 loc) · 2.4 KB
/
main.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
clear all
close all
clc
global GRAVITY BALLRADIUS INERTIA MASS DELTA_TIME PLOT_TIME STATIC_FRICTION KINETIC_FRICTION
% Edit these constants
KINETIC_FRICTION = 0.15;
STATIC_FRICTION = 0.3;
GRAVITY = -9.81;
BALLRADIUS = 0.007804912;
MASS = 0.00491240537;
INERTIA = (2/5)*MASS*BALLRADIUS^2;
BRACH_CURVATURE_VAR = 1;
DELTA_TIME = 0.001; % Smaller DELTA time increases precision of slope calculation
PLOT_TIME = 0.003; % Plot every ___ Seconds
INCH_TO_METER = 0.0254;
velocity = [0.01, -0.01];
time = 0;
position = [INCH_TO_METER, -INCH_TO_METER];
omega = 0;
slope_angle = pi/6;
final_slope_position = [0, 3];
energy_remain = 0.10;
addpath './curves'
addpath './objects'
[x_positions, y_positions, velocities, accelerations, time, position, omegas, alphas, omega] = slope(getOldVelocity(0), position, time, [1*INCH_TO_METER+position(1), -11*INCH_TO_METER+position(2)], omega);
[x_positions1, y_positions1, velocities1, accelerations1, time, position, omegas1, alphas1, omega] = brachistochrone(getOldVelocity(0), BRACH_CURVATURE_VAR, position, time, omega);
[x_positions2, y_positions2, velocities2, accelerations2, time, position, omegas2, alphas2, omega] = slope(getOldVelocity(0), position, time, [position(1)+ 2*INCH_TO_METER, position(2)], omega);
[x_positions3, y_positions3, velocities3, accelerations3, time, position, omegas3, alphas3, omega] = slope(getOldVelocity(0), position, time, [position(1)+ 8*INCH_TO_METER, position(2) + 3*INCH_TO_METER], omega);
[omega,impulse_acceleration,time] = bounce(energy_remain, getOldVelocity(0), time);
[x_positions4, y_positions4, velocities4, accelerations4, time, omegas4, alphas4] = free(getOldVelocity(0), time, position,position(1)+ 1*INCH_TO_METER, position(2) + 0.35*INCH_TO_METER,-0.889);
accelerations4(1) = impulse_acceleration;
x_positions = [x_positions x_positions1 x_positions2 x_positions3,x_positions4];
y_positions = [y_positions y_positions1 y_positions2 y_positions3,y_positions4];
velocities = [velocities velocities1 velocities2 velocities3,velocities4];
accelerations = abs([accelerations accelerations1 accelerations2,accelerations3,accelerations4]);
omegas = abs([omegas omegas1 omegas2 omegas3,omegas4]);
alphas = abs([alphas alphas1 alphas2 alphas3,alphas4]);
plotFunction(x_positions, y_positions, velocities, accelerations, time, alphas, omegas, position);
Time_taken = time;
disp('Final Velocity (m/s)')
disp(' V_x V_y')
disp(getOldVelocity(0))