-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslopeSlipping.m
executable file
·22 lines (17 loc) · 1.16 KB
/
slopeSlipping.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function[positionChange, finalVelocity, acceleration] = slopeSlipping(deltaPosition, isBrach)
global GRAVITY DELTA_TIME KINETIC_FRICTION MASS BALLRADIUS INERTIA MOVING_RIGHT MOVING_LEFT
acceleration = GRAVITY*sin(getTheta()) + KINETIC_FRICTION*GRAVITY*cos(getTheta());
if(isBrach)
delta_time = norm(deltaPosition) / norm([getOldVelocity(1), getOldVelocity(2)]);
finalVelocity = getOldVelocity(0) + acceleration*delta_time*[cos(getTheta()),sin(getTheta())];
positionChange = getOldVelocity(0)*delta_time + (1/2)*acceleration*[cos(getTheta()),sin(getTheta())]*delta_time^2;
else
if(getTheta() < 0)
finalVelocity = getOldVelocity(0) + abs(acceleration)*DELTA_TIME*[cos(getTheta()),sin(getTheta())];
positionChange = getOldVelocity(0)*DELTA_TIME + (1/2)*abs(acceleration)*[cos(getTheta()),sin(getTheta())]*DELTA_TIME^2;
else
finalVelocity = getOldVelocity(0) -abs(acceleration)*DELTA_TIME*[cos(getTheta()),sin(getTheta())];
positionChange = getOldVelocity(0)*DELTA_TIME + (1/2)*-abs(acceleration)*[cos(getTheta()),sin(getTheta())]*DELTA_TIME^2;
end
end
end