About the simple harmonic motion applet

    The shm.class applet animates a number of points each of which may move with simple harmonic motion in both the x and y directions.
    At time t the coordinates of a point are given by (xt , yt) where
    xt=x0+xscos(wxt+dx) and
    yt=y0+yssin(wyt+dy)
    The values x0 , y0 , xs , ys , wx , wy , dx and dy are parameters. They represent the centre of the motion, the amplitude, the angular velocity and the phase.

    The parameters for any number of points may be specified as applet parameter for example:

    <applet code=shm.class width=200 height=150> <param name=shm value= "0 0 300 0 4 0 0 0| 0 0 0 300 0 2 0 0" > </applet>
    This instance of the applet has two point (each specified by eight numbers) separated by a bar (|).
    The both points are centred at (0,0), the middle of the view window.
    The first point moves side to side as the x amplitude is 300 and the y amplitude is 0.
    The second point moves up and down.
    Note that the horizontal point moves twice as fast as the vertical one, it's angular velocity is 4 not 2.

    Parameters

    Parameter NameNotesDefault value
    bgcolor A 6 digit hex number giving the RGB colour of the background FFFFFF
    fgcolor A 6 digit hex number giving the RGB colour of the foreground 000000
    shmA number of points, each sepcified by 8 or 9 numbers each point separated by a bar |.
    shmsource The URL of a file containing the points data. The format of this data file is slightly different to the above. Each point must be given by a line of data (eight or nine number separated by spaces). Line starting with # are ignored.
    fps Frames Per Second - controls the attempted speed of animation 10
    squareWidth The size of the circle which is draw for each point. 2
    squish true or false. If squish is on the coordinates are mapped to an 800x600 rectangle with (0,0) at the centre of the window. true

    Drawing lines

    An optional nineth parameter may be given for any point.
    ValueMeaning
    0Plot a circle.
    1Plot a line from the previous position.
    2Move to this point without ploting anything.
    [Andrew's home page | Source code | SHM page]