The relevant conversions to screen coordinates etc. are automatically handeled by the superclass MechSystem . This way, you only need to worry about the physical properties of the mechanical system you are defining. As an example, we will examine how the class SpringPendulum is defined. Let l 0 and l 1 be the length of the inner and outer leg, where l 0 is the length of the spring in its relaxed state. Let k 0 be the spring constant.
Alpha is the angle of the outer leg, measured in radians counterclockwise from south.
We will now see how to translate this physical information into a Java class. First, you may declare any internal variables you are going to use. In this case, we also declare two integer variables that will hold the radii of the dots that will represent the two masses. Next, we need to define three methods that provide general information about the system. In the case of the spring pendulum, there are six parameters.