NetLogo User Community Models(back to the NetLogo User Community Models)

Download If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".
Try It in NetLogo Web

Model SPIRALS & CURVE MATCHING
BACKGROUND
Alternative procedures for displaying spirals are examined and a procedure for matching equations to curves is developed, which may have other applications. Anyone of three well known spirals can be displayed by selection at the CHOICE widget. The Archimedes spiral is generated by a rotation plus a constant velocity crossways displacement as in the case of a gramophone record, giving an equidistance spacing between the lines. Both the evolute and the logarithmic spirals are growth spirals in which the spacing between the lines increases.
The original spirals were generated with the polar, r/phi procedure, the more natural from a mathematical point of view; but to display conversion to cartesian coordinates was used.
The scale factor 's' can be adjusted to alter the spacing between the lines and therefore the "length" of the spirals displayed.
Following a comment made by Seth Tisue at CCL, June 2003, lt/fd procedures were explored and added as follows: Using from the r/phi procedure, the cartesian coordinates of calculations of 3 iterations, previous, now and next was a possibility. However completing the rightangled triangles between these and solving for lt and fd was somewhat clumsy; so a similar method using the polar radii of iterations, previous 'b1', now 'c' and next 'b2', was chosen: where A is the constant 0.5° angular step of the polar r/phi code ___a2__ ___a1__ hence 'a1' becomes the previous step forward or 'fd' of the lt/fd code \C2 B2B1 C1/ also 'a2' " " next " " " " " " " " \  / and 'B2'  'B1' becomes the angular step or 'lt' of the lt/fd code. b2\ cc /b1 \  / And the cosine formula a = sqroot[bxb + cxc  2xbxcxcosA] \  / also a/sinA = b/sinB = c/sinC are available. \AA/ \/ Overlaying the displays of the r/phi and lt/fd procedures shows that  the match is very good, including over the range of 's'.
It is possible to obtain an approximate match with a shorter procedure,identified as sh/lt/fd, by comparing the PLOTS of the sh/lt/fd equations with those of the lt/fd equations and modifying the sh/lt/fd equations to obtain a close fit. The results for the Archimedes spiral, (the simplest), are acceptable. The other equations have been left half finished for the amusement of model viewers who wish to try their hand at "fitting an equation to a curve techniques" and then overlaying the spiral that is generated to see if the match of sh/lt/fd against r/phi is good.
USING THE MODEL TO DISPLAY THE SPIRALS
First CHOOSE a spiral, select a value for 's' and press SETUP. Then RUN one procedure followed by another if observing the match by overlaying; otherwise press SETUP in between RUNNING procedures. It runs quicker with PLOTS switched OFF. The overlay with close matching is difficult to see, so r/phi writes in yellow, lt/fd writes in red and sh/lt/fd writes in lime. It may be instructive to run the r/phi procedure with PLOTS switched ON but not when fitting an equation to a curve, when it could be confusing.
USING THE MODEL TO FIT AN EQUATION TO A CURVE
First CHOOSE a spiral, select a value for 's' and press SETUP. With PLOTS switched ON the lt/fd procedure should be RUN to plot the curves of 'lt' and 'fd'; followed directly by the sh/lt/fd procedure to examine how closely its 'lt' and 'fd' plots follow those of lt/fd. The fit of these curves may suggest a change to the sh/lt/fd equations for 'lt'(beta) and 'fd'(delta) to obtain a better match when overlaying the spiral that is generated. If all else fails there is always the START conditions to give that last tweek to the match.
COMMENT
The START conditions, 'xcor', 'ycor' and 'heading' are important in acheiving a good match between the spirals generated by the r/phi procedure and by the lt/fd procedures. To assist this process code has been included to print these values in the COMMAND CENTER. The heading value can change the xcor&ycor figures. Over a 5 : 1 range of values of 's' it does appear possible to obtain a near perfect match of the spirals drawn by procedure r/phi and procedure lt/fd. Perhaps a perfect match of the displayed spirals is not possible because steps in the display result from finite pixel size.
The Author Derek Rush may be contacted by Email at derekrush@beeb.net October 2002 and July 2003.
