CYCLOIDS
by ThOMAS J. ANdREWS, AC CONTRibUTiNG AUThOR
Spirograph Fancier
As a boy, I was fascinated by Spirograph (tm). My freehand drawing abilities ranged from none to even less, and still do for that matter. The idea of being able to draw pretty designs by merely selecting a couple of gears, putting a pen in a hole, and running one gear around the other was great for a frustrated artist like me. I've never really outgrown it.
When I got older and went to Engineering School, I learned about the mathematic principles behind this toy. Using my new knowledge of polar coordinates and advanced trigonometry, I derived for myself the equations that describe it. It was very gratifying to later find these equations in a mathematics handbook, and to see that while my versions were in a slightly different form, they were correct.
Cycloids and Spirographs
When I started programming the Atari 800, several years later, it seemed only natural to transform my fascination for the Spirograph into a program. While I was at it, I added features that would be impossible for the original toy, but are quite possible mathematically. "Cycloids" is the result.
A cycloid is the general name for the family of equations which describes the movement of a point on a rolling circular object. This program works with two members of that family, where one circle rolls on the surface of another. When the moving circle rolls on the outside of the base, the curve is called an epicycloid. When the mover rolls on the inside of the base circumference, the curve is an endocycloid.
Cycloids and Gears
When using the Cycloids program, you need to imagine two gears. Each gear has exactly the same number of teeth as the size of the radius of the gear, and gears are identified by the total number of teeth on each.
The base gear is always stationary in the center of the screen, and may have its teeth on the inside or outside of its circumference. Available gear sizes range from 10 to 256 teeth.
The moving gear always has its teeth on the outside. There are holes drilled at evenly spaced intervals along the radius of the gear, from the center to the outside edge. These holes are numbered from 0 to the same number as the size of the gear. In addition, imagine a bar attached to the radius of the gear and extending that radius to four times its length. This bar also has holes drilled in it, evenly spaced at the same interval as those in the gear itself. It is into one of these holes that your pen will be placed for drawing.
Getting Started
Cycloids is very easy to use. You can RUN it from either AtariBASIC or Turbo BASIC XL, although I prefer Turbo BASIC because of the speed. Cycloids can't be used with the Turbo BASIC Compiler.
The program starts with an initialization period, during which a table of sine function values is created. Each point of a cycloid drawing requires the determination of four sine values, and it's much faster to look these up in a table while in the drawing loop than it would be to calculate them.
After the initialization, Cycloids presents you with a blank Graphics 8 screen. A list of commands will appear in the text window. If you want a demonstration of what Cycloids does, just press "N", for NEXT. Cycloids has the necessary parameters for a drawing all loaded. To pause the drawing and restore the command window, press any key at any time.
Command Explanations
Some commands change various parameters. "T" assigns the drawing type, either epicycloid or endocycloid. "G" changes the gears that are to be used. In these and other commands, to keep the same value in effect, just press RETURN with no entry in response to the request for a value.
The type and gear sizes determine the basic shape of the drawing. In every drawing, no matter which type or combination of gears, the pen will eventually return to the starting point, creating a cycle. Each cycle will contain a certain number of lobes. Some are more obvious than others, but they're there. The number of lobes can be determined by the values of the gears. To do this, create a fraction with the value of the moving gear in the numerator and the base in the denominator. Now, reduce this fraction to lowest terms. The denominator of the resulting fraction will contain the number of lobes in a cycle.
For example: 45/105=3/7 There will be seven lobes in this drawing cycle. Please note that in the above example, moving gears of 15, 30, 60, 75, and 90 will all make seven-lobed cycles when used with a 105 base. However, each of the drawings would have a different shape.
The command "B" changes the tooth alignment of the gears. Each tooth on the base gear is numbered from 1 to the gear number. When each drawing cycle is started, tooth #1 of the moving gear is aligned with the designated tooth of the base. Tooth #1 of the base always points toward the center right of the screen. Changing the number of the starting tooth has the effect of rotating the position of the drawing cycle on the screen. As an added feature, Cycloids can be set up to increment or decrement the value of the starting tooth between cycles.
"H" changes the hole that the pen is to be put into. In general, cycles using smaller values for the hole will tend to have smoother, more rounded corners. Using hole #0 will always produce a circle. Larger hole values will produce more pointed drawings, and values larger than the gear size may produce loops at the points. Like the starting tooth, the hole number can be set up to change between cycles.
"X" changes the scale of the drawing. This is determined by a combination of two values. The first is the scale factor, and the second is the scale base radius. The scale factor is the number of pixels used to display a radius of a circle the size of the scale base. Thus, if you were to draw a circle of radius 100 using a scale factor of 95 and a scale radius of 100, the circle would be 190 pixels in diameter, or nearly a full screen. To increase the size of a drawing, increase the scale factor or reduce the scale base radius, or both.
The "I" command cycles its way through the T, G, B, H, and X commands, in that order.
More Commands
The rest of the commands are more intuitive and easier to understand. "RETURN" will resume the drawing where you left off, finishing the current cycle before implementing any changes in parameters you might have made. "N" skips directly to the start of the next cycle. "C" clears the screen. "D" deletes the portion of the drawing done since the last time you saw the command window.
"P" toggles the automatic pause mode. If this is active, the program will return to command mode at the end of each cycle.
"S" saves the current drawing, usually to a disk file. The file created is a simple 62-sector screen dump, without color register information. This file can be used with many graphics programs, including Billboard. Billboard can be used to produce a printed copy of your drawings, in a multitude of sizes.
"L" will load a previously saved file, replacing whatever is on the screen at the time. The "D" command will still restore a former screen, though.
Infinite Possibilities
With a little practice and imagination, you can make thousands of different figures with Cycloids. Through proper use of the commands different designs can be superimposed over or within each other. Other manipulations can create interesting moire patterns through the use of Graphics 8 artifacting.
I couldn't possibly describe all that could be done. I've had hours of fun with Cycloids, both in programming it and using it. I hope you do, too.
[Author's Note: If you have trouble with the DELETE command, try this: LIST the program to disk, type NEW, then ENTER the LISTed file. Finally, SAVE a new copy to disk and RUN Cycloids. Questions?]
CYCLOIDS BASIC