2. WATT’S PARALLEL MOTION – JSP
The JSP Code

The JSP applet code given below was used to produce the diagram at right.

It is interesting that this apparently complicated window can be produced with less than 30 construction commands!

If you are like me, you are probably still finding errors are a problem. Make a note of the most likely causes. For me it is often the reference numbers { } – especially when lines of code are added late during the construction.

<APPLET CODE="GSP.class"
WIDTH=300 HEIGHT=350 ALIGN=left>
<PARAM NAME=Frame VALUE=1>
<PARAM NAME=BackRed VALUE=255>
<PARAM NAME=BackGreen VALUE=255>
<PARAM NAME=BackBlue VALUE=100>
<PARAM NAME=Construction VALUE="

{Define some segments to give fixed and variable lengths}
{1} FixedPoint (50, 20) [red];
{2} FixedPoint (120, 20); {determines length 70}
{3} Ray (2, 1) [hidden];
{4} Point on object (3, 1);
{5} Segment (1, 4) [red, thick];

{6} FixedPoint (50, 40) [green];
{7} FixedPoint (150, 40); {determines length 100}
{8} Ray (7, 6) [hidden];
{9} Point on object (8, 1);
{10} Segment (6, 9) [green, thick];

{Link point A}
{11} FixedPoint (100, 150) [blue, label('A')];

{Link point B}
{12} FixedPoint (200, 150) [blue, label('B')];

{Point P}
{13} Circle by radius (11, 5) [hidden];
{14} Point on object (13, -0.84) [label('P')];

{Point Q}
{15} Circle by radius (12, 5) [hidden];
{16} Circle by radius (14, 10) [hidden];
{17} Intersect1(15, 16) [green, label('Q')];

{Point M}
{18} Segment (14, 17) [thick, green];
{19} Midpoint (18) [black, label('M')];

{Segments AP, BQ}
{20} Segment (11, 14) [thick, red];
{21} Segment (12, 17) [thick, red];

{Trace path}
{22} Translation (19, 1, 0) [hidden, traced];
{23} Line (11, 12) [hidden];
{24} Reflection (22, 23) [hidden, traced];

{Buttons}
{25} ShowButton (0, 298, 'Trace on') (22, 24);
{26} HideButton (0, 325, 'Trace off') (22, 24);

{27} ShowButton (80, 298, 'Reflection on') (24);
{28} HideButton (80, 325, 'Reflection off') (24);

">
</APPLET>



We are settling for a yellow background for this applet.


We will be using lengths 70 and 100 (close to 702), but we want to allow the setting of different lengths as well. So we make visible, adjustable horizontal segments at the top of the JSP window. The two fixed points {2} and {7} give settings for the lemniscate.
The second number (1) in {3} and {9} initially places the variable point on top of the above fixed point.






Points A and B are fixed 100 units apart. These fix the linkage in the plane.




Point P lies on a circle centre A. The initial radius of this circle is 70. The number -0.84 is a radian measure defining the point position on the circle.

Point Q lies on a circle centre B, and a fixed distance (which can be varied!) from P.


M is the midpoint of PQ.



Colour in the segments.


This is the same fudge we used last time for trace paths. Beacuse the linkage only generates half our expected figure, we reflect the path in line AB.

Finally we add buttons to set the trace and the reflection on or off.

Exercises

1. Play with the applet using different values of the slider lengths. What range of figures can be generated in this way?

2. The adjustable sliders for the lengths seem an easy addition. Return to your pantograph program and introduce them there.

3. In the modified Watt’s linkage aat right, A and G are fixed pivots. The basic linkage is AB – BE – EG. Write a program to demonstrate this linkage.