I thought I would make a mechanics problem for all those physics lovers out there.
Imagine two solid, rigid spheres B1 and B2 with radius R1 and R2 and mass M1 and M2. B1 initially has its center of mass at the origin and is confined to always move along the x axis. B2 has its center of mass located at coordinates (x2,y2) where 0<x2<(R1+R2) and sqrt((R1+R2)^2-x2^2)<y2. Gravity acts in the negative y direction with constant g = 9.8 in some consistent unit system.
Write a function that returns the velocity of both spheres after B2 is allowed to fall, assuming a lossless collision occurs. Keep in mind that the answers should be two-element row vectors. For example, if R1=1, R2=.25, M1=2, M2=4, x2=.5 and y2=6, then:
[V1,V2] = balldrop_puzz(M1,M2,R1,R2,x2,y2)
V1 = [-10.8362631979321 0] V2 = [5.41813159896603 2.66024980473149]
MATLAB and Simulink resources for Arduino, LEGO, and Raspberry PiLearn more
Opportunities for recent engineering grads.Apply Today
New to MATLAB?Learn MATLAB today!
Play games and win prizes!Learn more