Elastic Collisions & Sierpinski Carpet Anakaren Santana
Elastic Collisions
Method 1.Set up initial conditions (make sure both masses will actually collide). 2.For loop changes positions of the masses according to their respective velocities. 3.An if statement checks if the masses collide. When they collide the new velocities are calculated and initial positions reset. 4.A second for loop changes the positions of the masses according to these new velocities and initial coordinates.
1D: m1=2 m2=2, U1=2 U2=0, x01=0 x02=20 Run Code With: elasticCollision.m
2D: m1=2 m2=4, Ux1=4 Uy2=4, Ux2=-1 Uy2=-1, x01=-90 y01=-90, x02=90 y02=90 Run Code With: elasticCollision2D.m
The Sierpinski Carpet is a fractal of fractal dimension It begins with a square that you divide into 9 sub-squares and remove the center square. Repeat the process with each subsquare. Method: – Nested for loops within a while loop. – The while loop ensures that we can keep dividing by 3. – The nested for loops “remove” the appropriate squares in each iteration.