% 2-Particle collisions % Andy Ruina, modified Oct 3, 2006 % See lecture notes from Oct 3, 2006 for % basic problem setup. theta = 0; % angle between n and plus x axis nx = cos(theta); ny = sin(theta); n = [nx ny]'; %Impulse direction v1bef = [ 1 0]'; %vel of m1 before collision v2bef = [ 0 0]'; %vel of m2 before collision m1 = 1; m2 = 1; %values of two masses e = 1; % coefficient of restitution %Write governing equations in form of Az=b %where z is a list of unknowns representing %the particle velocities after the collision %and the magnitude of the impulse. A = [ m1 0 m2 0 0 %x comp of lin mom bal 0 m1 0 m2 0 %y comp of lin mom bal -nx -ny nx ny 0 %restitution equation 0 0 m2 0 -nx %impulse-momentum for m2, x comp 0 0 0 m2 -ny] %impulse-momentum for m2, y comp b = [m1*v1bef + m2*v2bef; % x&y comps of lin mom bal for syst -e*sum((v2bef-v1bef).*n); % restitution equation, note dot product m2*v2bef] % impulse-momentum for m2, x & y comps %Matlab command for solving simultaneous equations %of form Az=b for z, where A and b are known. z= A\b; % The greatest command in all of Matlab. %Type out the solution (crudely). ' v1xaft v1yaft v2xaft v2yaft P' z'