This class embeds all the necessary code to create a virtual lab to study the static equilibrium of an object suspended on a clothesline with a counterweight.
self.m_counterweight_note=Label('[Note: once you have clicked on the slider (the circle becomes blue), you can use the arrows from your keyboard to make it move.]',layout=Layout(margin='0px 0px 15px 0px'))
# Let's check that there is actually a counterweight
ifm_counterweight>0:
# Then we compute the ratio of masses
ratio=0.5*self.m_object/m_counterweight
# Check that the ratio of masses is in the domain of validity of arcsin ([-1;1])
ifabs(ratio)<1:
alpha=np.arcsin(ratio)
returnmin(alpha_default,alpha)
defget_object_coords(self,angle):
"""
Computes the position of the object on the cable taking into account the angle determined by the counterweight and the dimensions of the hanging system.
By default:
- the object is supposed to be suspended exactly in the middle of the cable
- the object is considered on the ground for all values of the angle which give a height smaller than the height of the poles
:angle: angle that the cable makes with the horizon
:returns: coordinates of the point at which the object are hanged
"""
# the jean is midway between the poles
x_object=self.x_origin+0.5*self.distance
# default y value: the jean is on the ground
y_object=self.y_origin
# we check that the angle is comprised between horizontal (greater than 0) and vertical (smaller than pi/2)
ifangle>0andangle<(np.pi/2):
# we compute the delta between the horizon and the point given by the angle
delta=(0.5*self.distance*np.tan(angle))
# we check that the delta is smaller than the height of the poles (otherwise it just means the jean is on the ground)