home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 301_02 / trigger.c < prev    next >
Text File  |  1989-12-30  |  39KB  |  1,143 lines

  1. /*
  2. HEADER:        ;
  3. TITLE: trigger.c   
  4.        trigonometric implementations of the Borland Graphics Interface;
  5. VERSION:  1.0;
  6.  
  7. DESCRIPTION: horsing around with trig functions and the Borland Graphics
  8.    Interface (BGI).  This program was created and run on a Compaq Plus
  9.    and an IBM AT with a CGA card using Borland's TurboC 2.0.  Routines
  10.    and variables with a single, initial capital letter (i.e. MainWindow())
  11.    are taken directly from the demo program accompanying TurboC 2.0.
  12.    The file CGA.BGI is likewise directly from the TurboC disk.  In theory
  13.    by including a .BGI file for every conceivable combination of video
  14.    cards and allowing the program to auto detect the card one could make it
  15.    universally adaptable.  In this case, however, the medium resolution
  16.    mode of the CGA card is forced.  To allow for other cards, one could
  17.    initiate the sequence--
  18.            GraphDriver = DETECT;
  19.            initgraph( &GraphDriver, &GraphMode, "" );
  20.    but this would require all of the *.BGI files to be available on disk
  21.    or compiled within the program.
  22.    In addition several of the Borland routines are specific to IBM and
  23.    close compatibles so that the program is not very portable as written.
  24.    The Borland file 'graphics.h' contains the definitions for many of the
  25.    global variables specific for their functions (e.g. DETECT).
  26.  
  27. KEYWORDS: trig functions, BGI, Borland Graphics Interface, TurboC;
  28. SYSTEM:   MSDOS;
  29. FILENAME: TRIGGER.C;
  30. WARNINGS: Expects CGA card, will not run on monochrome
  31.           must have CGA.BGI on same directory or path to it;
  32. SEE-ALSO: TRIGGER.EXE;
  33. AUTHORS:  Henry Pollock;
  34. COMPILERS:  TurboC 2.0;
  35. */
  36.  
  37. /*
  38. --  TRIGGER.C  horsing around with trig functions and the Borland Graphics
  39. --             Interface (BGI).
  40. --                               Henry Pollock
  41. --                               Essex Center Drive
  42. --                               Peabody, MA 01960
  43. --                               7/15/89
  44. */
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. #include <conio.h>
  53. #include <dos.h>
  54. #include <graphics.h>
  55. #include <math.h>
  56. #include <stdarg.h>
  57. #include <stdio.h>
  58. #include <stdlib.h>
  59.  
  60. #define CTR_X_ORIGIN X_OFFSET + (MaxX - X_OFFSET)/2
  61. #define CTR_Y_ORIGIN Y_OFFSET + (MaxY - Y_OFFSET)/2
  62. #define ESC    0x1b           /* Define the escape key */
  63. #define FALSE  0              /* Define some handy constants     */
  64. #define OFF    0              /* Define some handy constants     */
  65. #define ON     1              /* Define some handy constants     */
  66. #define PI     3.14159        /* Define a value for PI */
  67. #define SW_X_ORIGIN X_OFFSET
  68. #define SW_Y_ORIGIN MaxY - Y_OFFSET
  69. #define TRUE   1              /* Define some handy constants     */
  70.  
  71.  
  72.  
  73.  
  74.  
  75. double AspectRatio;      /* Aspect ratio of a pixel on the screen*/
  76. int    ErrorCode;        /* Reports any graphics errors          */
  77. int    GraphDriver;      /* The Graphics device driver      */
  78. int    GraphMode;        /* The Graphics mode value         */
  79. int    MaxColors;        /* The maximum # of colors available    */
  80. int    MaxX, MaxY;       /* The maximum resolution of the screen */
  81. int    X_OFFSET = 0;
  82. int    Y_OFFSET = 0;
  83.  
  84.  
  85. /*Routines from Borland Demo Disk */
  86. int  gprintf(int *xloc, int *yloc, char *fmt, ... );
  87. void changetextstyle(int font, int direction, int charsize);
  88. void DrawBorder(void);
  89. void Initialize(void);
  90. void MainWindow(char *header);
  91. void StatusLine(char *msg);
  92.  
  93. /*Trig routines*/
  94.  
  95. int menu();
  96. int scale_x(float *, float *);
  97. int scale_y(float *, float *);
  98. void asteroid();
  99. void autoloid();
  100. void circloid();
  101. void cycloids();
  102. void ctr_graph_plot();
  103. void draw_circleoid(int *, int *, float *);
  104. void get_params2(float *power);
  105. void get_params8(char *cycloid, int *cusps);
  106. void draw_roulette(char *cycloid, int *cusps);
  107. void lissajous();
  108. void logo();
  109. void spiral();
  110. void sw_graph_plot();
  111. void tschirnhausen();
  112. void roulettes();
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120. void changetextstyle(int font, int direction, int charsize)
  121. {
  122.     int ErrorCode;
  123.  
  124.     graphresult();              /* clear error code      */
  125.     settextstyle(font, direction, charsize);
  126.     ErrorCode = graphresult();       /* check result          */
  127.     if( ErrorCode != grOk ){         /* if error occured      */
  128.         closegraph();
  129.         printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
  130.         exit( 1 );
  131.     }
  132. }
  133.  
  134.  
  135. int gprintf( int *xloc, int *yloc, char *fmt, ... )
  136. {
  137.     va_list  argptr;            /* Argument list pointer */
  138.     char str[140];              /* Buffer to build sting into */
  139.     int cnt;                    /* Result of SPRINTF for return */
  140.  
  141.     va_start( argptr, format );      /* Initialize va_ functions   */
  142.  
  143.     cnt = vsprintf( str, fmt, argptr );   /* prints string to buffer    */
  144.     outtextxy( *xloc, *yloc, str );  /* Send string in graphics mode */
  145.     *yloc += textheight( "H" ) + 2;       /* Advance to next line         */
  146.  
  147.     va_end( argptr );           /* Close va_ functions        */
  148.  
  149.     return( cnt );              /* Return the conversion count     */
  150.  
  151. }
  152.  
  153. void DrawBorder(void)
  154. {
  155.     struct viewporttype vp;
  156.  
  157.     setcolor( MaxColors - 1 );       /* Set current color to white */
  158.  
  159.     setlinestyle( SOLID_LINE, 0, NORM_WIDTH );
  160.  
  161.     getviewsettings( &vp );
  162.     rectangle( 0, 0, vp.right-vp.left, vp.bottom-vp.top );
  163.  
  164. }
  165.  
  166.  
  167. void MainWindow( char *header )
  168. {
  169.     int height;
  170.  
  171.     cleardevice();              /* Clear graphics screen */
  172.     setcolor( MaxColors - 1 );       /* Set current color to white */
  173.     setviewport( 0, 0, MaxX, MaxY, 1 );   /* Open port to full screen   */
  174.  
  175.     height = textheight( "H" );           /* Get basic text height        */
  176.  
  177.     changetextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );
  178.     settextjustify( CENTER_TEXT, TOP_TEXT );
  179.     outtextxy( MaxX/2, 2, header );
  180.     setviewport( 0, height+4, MaxX, MaxY-(height+4), 1 );
  181.     DrawBorder();
  182.     setviewport( 1, height+5, MaxX-1, MaxY-(height+5), 1 );
  183.  
  184. }
  185.  
  186.  
  187. void Initialize(void)
  188. {
  189.     int xasp, yasp;             /* Used to read the aspect ratio*/
  190.  
  191.     GraphDriver = CGA;         /* force cga                  */
  192.     GraphMode   = CGAC1;       /* cyan,magenta,white         */
  193.     initgraph( &GraphDriver, &GraphMode, "" );
  194.     ErrorCode = graphresult();       /* Read result of initialization*/
  195.     if( ErrorCode != grOk ){         /* Error occured during init  */
  196.         printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
  197.         exit( 1 );
  198.     }
  199.  
  200.     MaxColors = getmaxcolor() + 1;   /* Read maximum number of colors*/
  201.  
  202.     MaxX = getmaxx();
  203.     MaxY = getmaxy();           /* Read size of screen        */
  204.  
  205.     getaspectratio( &xasp, &yasp );  /* read the hardware aspect   */
  206.     AspectRatio = (double)xasp / (double)yasp; /* Get correction factor */
  207.  
  208. }
  209.  
  210. void StatusLine( char *msg )
  211. {
  212.     int height;
  213.     setviewport( 0, 0, MaxX, MaxY, 1 );   /* Open port to full screen   */
  214.     setcolor( MaxColors - 1 );       /* Set current color to white */
  215.     changetextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );
  216.     settextjustify( CENTER_TEXT, TOP_TEXT );
  217.     setlinestyle( SOLID_LINE, 0, NORM_WIDTH );
  218.     setfillstyle( EMPTY_FILL, 0 );
  219.     height = textheight( "H" );           /* Detemine current height      */
  220.     bar( 0, MaxY-(height+4), MaxX, MaxY );
  221.     rectangle( 0, MaxY-(height+4), MaxX, MaxY );
  222.     outtextxy( MaxX/2, MaxY-(height+2), msg );
  223.     setviewport( 1, height+5, MaxX-1, MaxY-(height+5), 1 );
  224.  
  225. }
  226.  
  227. /*#################################################*/
  228.  
  229. void main()  {
  230.     int menu_nbr;
  231.     char again = 'y';
  232.     Initialize();
  233.     while  (again == 'y')   {
  234.         restorecrtmode();
  235.         clrscr();
  236.         logo();
  237.         menu_nbr = menu();
  238.         switch (menu_nbr) {
  239.         case 1:
  240.             autoloid();
  241.             break;
  242.         case 2:
  243.             circloid();
  244.             break;
  245.         case 3:
  246.             asteroid();
  247.             break;
  248.         case 4:
  249.             spiral();
  250.             break;
  251.         case 5:
  252.             lissajous();
  253.             break;
  254.         case 6:
  255.             tschirnhausen();
  256.             break;
  257.         case 7:
  258.              cycloids();
  259.              break;
  260.         case 8:
  261.              roulettes();
  262.              break;
  263.         case 9:
  264.             again = 'n';
  265.             closegraph();
  266.         }
  267.     }
  268. }
  269. /*#################################################*/
  270.  
  271.  
  272. void logo()
  273. {
  274.  printf("\n╔═══════════════════════════════════════════════════════════╗"
  275.         "\n║ serious software from                                     ║"
  276.         "\n║                                                           ║"
  277.         "\n║         I A T R O G E N I C   S O F T W A R E             ║"
  278.         "\n║             Essex Center Drive - Suite 205                ║"
  279.         "\n║            Peabody, Massachusetts 01960-2972              ║"
  280.         "\n║                                                           ║"
  281.         "\n║             you know its serious ....  when its iatrogenic║"
  282.         "\n╚═══════════════════════════════════════════════════════════╝");
  283. }
  284.  
  285.  
  286. int menu()   {
  287.     int x,y,z;
  288.     char zz[2];
  289.  printf("\n    ┌──────────────────────────────────────────────┐"
  290.         "\n    │  TRIGONOMETRIC CURVES culled from            │"
  291.         "\n    │                    VARIOUS SOURCES           │"
  292.         "\n    │                                              │"
  293.         "\n    │  1. CIRCLES                                  │"
  294.         "\n    │  2. MAKE A CIRCLEOID                         │"
  295.         "\n    │  3. ASTEROID AND OTHERS                      │"
  296.         "\n    │  4. SPIRALS                                  │"
  297.         "\n    │  5. LISSAJOUS or BOWDITCH CURVE              │"
  298.         "\n    │  6. TSCHIRNHAUSEN'S CUBIC or l'HOPITAL'S     │"
  299.         "\n    │     or TRISECTRIX of CATALAN                 │"
  300.         "\n    │  7. CYCLOIDS                                 │"
  301.         "\n    │  8. MAKE A CYCLOID                           │"
  302.         "\n    │  9. QUIT                                     │"
  303.         "\n    │                   which choice ?             │"
  304.         "\n    └──────────────────────────────────────────────┘");
  305.  
  306.     x = wherex() - 13;
  307.     y = wherey() - 1;
  308.      while  ( (atoi(zz) <1 ) || ( atoi(zz) > 9) )  {
  309.         gotoxy(x,y);
  310.         printf(" \b");
  311.           scanf("%1s",zz);
  312.     }
  313.     z = atoi(zz);
  314.     return(z);
  315. }
  316.  
  317.  
  318. void sw_graph_plot()          {
  319.     setcolor(MaxColors-3);
  320.     setlinestyle(SOLID_LINE,0,THICK_WIDTH);
  321.     moveto(SW_X_ORIGIN, SW_Y_ORIGIN);
  322.     lineto(SW_X_ORIGIN,Y_OFFSET);
  323.     moveto(SW_X_ORIGIN, SW_Y_ORIGIN);
  324.     lineto(MaxX, SW_Y_ORIGIN);
  325.     setlinestyle(SOLID_LINE,0,NORM_WIDTH);
  326. }
  327.  
  328. void ctr_graph_plot()         {
  329.     setcolor(MaxColors-3);
  330.     setlinestyle(SOLID_LINE,0,THICK_WIDTH);
  331.     moveto(CTR_X_ORIGIN, 0);
  332.     lineto(CTR_X_ORIGIN, MaxY);
  333.     moveto(X_OFFSET, CTR_Y_ORIGIN);
  334.     lineto(MaxX, CTR_Y_ORIGIN);
  335.     setlinestyle(SOLID_LINE,0,NORM_WIDTH);
  336. }
  337.  
  338.  
  339. void lissajous()         {
  340.     double t;
  341.     float x,y,a,b,c,d,f;
  342.     int x_plot,y_plot,color,mode,again,x_out,y_out;
  343.     mode = getgraphmode();
  344.     setgraphmode( mode );
  345.     MainWindow( "Bowditch Sine Curves" );
  346.     StatusLine( "Return quits" );
  347.     ctr_graph_plot();
  348.     settextjustify(LEFT_TEXT, TOP_TEXT);
  349.     x_out = 10;
  350.     y_out = 10;
  351.     gprintf(&x_out,&y_out,"Equation:      x = sin(c*t),                y = sin(t) ");
  352.     gprintf(&x_out,&y_out,"for t = 1 to 100");
  353.     again = 'y';
  354.     while ( again == 'y' || again == 'Y') {
  355.         color = 0 ;
  356.         d = 0;
  357.         c = .2;
  358.         for (c = .25; c <= 1.0; c += .25)  {
  359.             if( kbhit())   break;
  360.             color +=1 ;
  361.             if (color == MaxColors) color = 1;
  362.             gprintf(&x_out,&y_out,"c = %.2f",c);
  363.             for( t = 0; t <= 100; t+=.1) {
  364.                 if( kbhit())   break;
  365.                 x = ((MaxX-X_OFFSET)/3) * (sin((c*t) + d));
  366.                 y = ((MaxY-Y_OFFSET)/3) * (sin(t));
  367.                 x_plot = (int)x + CTR_X_ORIGIN;
  368.                 y_plot = (int)y + CTR_Y_ORIGIN;
  369.                 putpixel(x_plot, y_plot,color);
  370.             }
  371.         }
  372.         gprintf(&x_out,&y_out,"all done");
  373.  
  374.         again = getche() ;
  375.     }
  376. }
  377.  
  378.  
  379.  
  380. void tschirnhausen()          {
  381.     float x,y,a,t,f;
  382.     int x_out,y_out,x_plot,y_plot,x_range,y_range,again,mode;
  383.  
  384.     a = 1;
  385.     x_range = 60;
  386.     y_range = 140;
  387.  
  388.     mode = getgraphmode();
  389.     setgraphmode( mode );
  390.     MainWindow( "Family of Tschirnhausen Curves" );
  391.     StatusLine( "Return quits" );
  392.     settextjustify(LEFT_TEXT, TOP_TEXT);
  393.     x_out = 10;
  394.     y_out = 10;
  395.     gprintf(&x_out,&y_out,"Equation:      x = 3a(t^2 - 3)               y = at(t^2 - 3)");
  396.     gprintf(&x_out,&y_out,"for t from -4.4 to +4.4");
  397.     again = 'y';
  398.     while ( again == 'y' || again == 'Y') {
  399.         ctr_graph_plot();
  400.         for( a = .5; a <=5; a+=.5) {
  401.             gprintf(&x_out,&y_out,"a = %.1f",a);
  402.             for (t = -4.4; t <= 4.4; t+=.02)  {
  403.                 if  ( kbhit())   break;
  404.                 x = 3 * a * ((t * t) - 3);
  405.                 y = a * t * ((t * t) - 3);
  406.  
  407.                 x_plot = (int)x * (180/x_range) + CTR_X_ORIGIN;
  408.                 y_plot = (int)y * (200/y_range) + CTR_Y_ORIGIN;
  409.  
  410.                 putpixel(x_plot, y_plot, MaxColors-2);
  411.             }
  412.         }
  413.         gprintf(&x_out,&y_out,"all done");
  414.         again = getche() ;
  415.     }
  416. }
  417.  
  418.  
  419.  
  420.  
  421. void spiral()          {
  422.  
  423.     double x,y,r,rr,a,aa,theta,m;
  424.     int x_plot,y_plot,x_range,y_range,mode,again,color;
  425.     mode = getgraphmode();
  426.     setgraphmode( mode );
  427.     settextjustify(LEFT_TEXT, TOP_TEXT);
  428.     ctr_graph_plot();
  429.     again = 'y';
  430.     while ( again == 'y' || again == 'Y') {
  431.  
  432.         x_range = 30;  /* screen is 320 x 200   so 150 % x 20 & 32 */
  433.         y_range = 48;
  434.         color = 1;
  435.         MainWindow( " x = 0cos(0), y = 0sin(0)" );
  436.         StatusLine( "Archemedian: Return Advances" );
  437.         color += 1;
  438.         if (color == MaxColors) color = 1;
  439.         for ( theta = 0; theta <= 8*PI; theta += .05) {
  440.             if  ( kbhit())   break;
  441.             x = theta * cos(theta);
  442.             y = theta * sin(theta);
  443.  
  444.             x_plot = (int)(x * (180/x_range)) + CTR_X_ORIGIN;
  445.             y_plot = (int)(y * (200/y_range)) + CTR_Y_ORIGIN;
  446.             putpixel(x_plot, y_plot, color);
  447.         }
  448.         again = getch();
  449.  
  450.         MainWindow( " x =(e^0)cos(0), y = (e^0)sin(0)" );
  451.         StatusLine( "Logarithmic: Return Advances" );
  452.         color += 1;
  453.         if (color == MaxColors) color = 1;
  454.  
  455.         for ( theta = 0; theta <= 8*PI; theta += .05) {
  456.             if  ( kbhit())   break;
  457.             x = (exp(theta*.25)*cos(theta))/10;
  458.             y = (exp(theta*.25)*sin(theta))/10;
  459.  
  460.             x_plot = (int)(x * (180/x_range)) + CTR_X_ORIGIN;
  461.             y_plot = (int)(y * (200/y_range)) + CTR_Y_ORIGIN;
  462.  
  463.             putpixel(x_plot, y_plot, color);
  464.         }
  465.         again = getch();
  466.  
  467.         MainWindow( " x = (1/0)cos(0), y = (1/0)sin(0)" );
  468.         StatusLine( "Hyperbolic: Return Advances" );
  469.         color += 1;
  470.         if (color == MaxColors) color = 1;
  471.         for ( theta = .05; theta <= 8*PI; theta += .05) {
  472.             if  ( kbhit())   break;
  473.             x = (30/theta) * cos(theta);
  474.             y = (50/theta) * sin(theta);
  475.  
  476.             x_plot = (int)(x * (180/x_range)) + CTR_X_ORIGIN;
  477.             y_plot = (int)(y * (200/y_range)) + CTR_Y_ORIGIN;
  478.  
  479.             putpixel(x_plot, y_plot, color);
  480.         }
  481.         again = getch();
  482.     }
  483.  
  484. }
  485.  
  486.  
  487. void autoloid()          {
  488.     float power;
  489.     int mode, x_out, y_out, again;
  490.     mode = getgraphmode();
  491.     setgraphmode( mode );
  492.     MainWindow( "Modifications of a Circle" );
  493.     StatusLine( "Return quits" );
  494.     settextjustify(LEFT_TEXT, TOP_TEXT);
  495.     ctr_graph_plot();
  496.     again = 'y';
  497.     while ( again == 'y' || again == 'Y') {
  498.         for(power = .5; power <= 3; power = power + .5) {
  499.             if  ( kbhit())   break;
  500.             draw_circleoid(&x_out, &y_out, &power);
  501.             if (power == 3)  {
  502.                 setcolor( MaxColors - 1 );
  503.                 gprintf(&x_out,&y_out,"all done");
  504.             }
  505.         }
  506.      again = getche() ;
  507.      }
  508. }
  509.  
  510.  
  511.  
  512. void draw_circleoid(int *x_out, int *y_out, float *power)  {
  513.     float radius, x_range, y_range, x, y_pos, y_neg;
  514.     int x_plot, y_plot, x_plot_old, y_plot_old, x_scaled, y_scaled, color;
  515.  
  516.  
  517.     radius =30;
  518.     x_range = radius * 3;
  519.     y_range = radius * 3;
  520.     *x_out = 10;
  521.     *y_out = 10;
  522.     *y_out +=  (textheight( "H" )+2) ;   /* advance prior to back up    */
  523.     *y_out -=  (textheight( "H" )+2) ;   /* back up to prior line       */
  524.     setcolor(OFF);
  525.     gprintf(x_out,y_out,"A^%2.1lf+B^%2.1lf=C^%2.1lf", *power-.5,*power-.5,*power-.5);
  526.     *y_out -=  (textheight( "H" )+2) ;   /* back up to prior line       */
  527.     setcolor( MaxColors - 1 );        /* Set current color to white */
  528.     gprintf(x_out,y_out,"A^%2.1lf+B^%2.1lf=C^%2.1lf",*power,*power,*power);
  529.     x_plot_old = CTR_X_ORIGIN;
  530.     y_pos = radius;
  531.     y_plot_old = CTR_Y_ORIGIN - scale_y(&y_pos, &y_range);
  532.  
  533.     setcolor( MaxColors - 2 );
  534.     for ( x = 1; x <= radius ; x++) {
  535.         if  ( kbhit())   break;
  536.         y_pos = pow ( (  (pow(radius,*power))-(pow(x,*power))  ), 1/(*power));
  537.         x_scaled = scale_x(&x, &x_range) ;
  538.         y_scaled = scale_y(&y_pos, &y_range);
  539.         x_plot = CTR_X_ORIGIN + x_scaled ;
  540.         y_plot = CTR_Y_ORIGIN - y_scaled;
  541.  
  542.         line(x_plot_old,y_plot_old,x_plot,y_plot);
  543.         x_plot_old = x_plot;
  544.         y_plot_old = y_plot;
  545.     }
  546.  
  547.     for ( x = radius; x >= 1 ; x--) {
  548.         if  ( kbhit())   break;
  549.         y_pos = pow ( (  (pow(radius,*power))-(pow(x,*power))  ), 1/(*power));
  550.         x_scaled = scale_x(&x, &x_range) ;
  551.         y_scaled = scale_y(&y_pos, &y_range);
  552.         x_plot = CTR_X_ORIGIN + x_scaled ;
  553.         y_plot = CTR_Y_ORIGIN + y_scaled;
  554.         line(x_plot_old,y_plot_old,x_plot,y_plot);
  555.         x_plot_old = x_plot;
  556.         y_plot_old = y_plot;
  557.     }
  558.  
  559.     for ( x = 1; x <= radius ; x++) {
  560.         if  ( kbhit())   break;
  561.         y_pos = pow ( (  (pow(radius,*power))-(pow(x,*power))  ), 1/(*power));
  562.         x_scaled = scale_x(&x, &x_range) ;
  563.         y_scaled = scale_y(&y_pos, &y_range);
  564.         x_plot = CTR_X_ORIGIN - x_scaled ;
  565.         y_plot = CTR_Y_ORIGIN + y_scaled;
  566.         line(x_plot_old,y_plot_old,x_plot,y_plot);
  567.         x_plot_old = x_plot;
  568.         y_plot_old = y_plot;
  569.     }
  570.  
  571.     for ( x = radius; x >= 1 ; x--) {
  572.         if  ( kbhit())   break;
  573.         y_pos = pow ( (  (pow(radius,*power))-(pow(x,*power))  ), 1/(*power));
  574.         x_scaled = scale_x(&x, &x_range) ;
  575.         y_scaled = scale_y(&y_pos, &y_range);
  576.         x_plot = (int)CTR_X_ORIGIN - x_scaled ;
  577.         y_plot = (int)CTR_Y_ORIGIN - y_scaled;
  578.         line(x_plot_old,y_plot_old,x_plot,y_plot);
  579.         x_plot_old = x_plot;
  580.         y_plot_old = y_plot;
  581.     }
  582.  
  583.  
  584. }
  585.  
  586.  
  587.  
  588. scale_x(float *formula_x, float *x_range)
  589. {
  590.     float x;
  591.     x = ( *formula_x / *x_range ) *  (MaxX - X_OFFSET) * 3/4;
  592.     return (int)x;
  593. }
  594.  
  595.  
  596.  
  597.  
  598. scale_y(float *formula_y, float *y_range)
  599. {
  600.     float y;
  601.     y = (*formula_y / *y_range) * ( MaxY - Y_OFFSET) ;
  602.     return (int)y;
  603. }
  604.  
  605. void get_params8(char *cycloid, int *cusps)  {
  606.     char ch ;
  607.     restorecrtmode();
  608.     clrscr();
  609.     gotoxy(0,4);
  610.     printf
  611. ("The common cycloid was traced by a peripheral point on a rolling circle.\n"
  612. "The prolate cycloid was traced by a point within the rolling circle\n"
  613. "If one rolls the circle around another, fixed, circle instead of\n"
  614. "along a straight line; then the point on the rim of the rolling\n"
  615. "circle traces an epicycloid, while the one within the circle traces a\n"
  616. "hypocycloid.  The size of the rolling circle in comparison to the\n"
  617. "fixed circle determines the number of cusps; and this determines\n"
  618. "the shape of the figure.  These figures are called roulettes, \n"
  619. "and they include the asteroid and the nephroid which \n"
  620. "were drawn above by entirely different means.  An epicycloid with 1 \n"
  621. "cusp is a cardioid, a hypocycloid with 4 cusps is an asteroid.");
  622.     ch =  'x';
  623.     *cycloid  = 'x';
  624.     *cusps    =  0;
  625.     do         {
  626.         while (!( ((*cycloid=='E') || (*cycloid=='e'))
  627.                 ||((*cycloid=='H')||(*cycloid=='h'))))  {
  628.             gotoxy(30,15);
  629.             clreol();
  630.             printf("Either Epicycloid or Hypocycloid > 0");
  631.             gotoxy(30,16);
  632.             clreol();
  633.             printf("Enter an 'e' or an 'h' ?  ");
  634.             scanf("%c",cycloid);
  635.         }
  636.  
  637.         while (!((*cusps > 0 ))) {
  638.             gotoxy(30,18);
  639.             clreol();
  640.             printf("The number of cusps must be > 0");
  641.             gotoxy(30,19);
  642.             clreol();
  643.             printf("What should the number be?  ");
  644.             scanf("%d",cusps);
  645.         }
  646.  
  647.         while (!( ((ch=='y') || (ch=='Y'))||((ch=='n')||(ch=='N'))))  {
  648.             gotoxy(30,21);
  649.             clreol();
  650.             ((*cycloid=='E') || (*cycloid=='e'))
  651.             ? printf("Epicycloid")
  652.             :   printf("Hypocycloid");
  653.             gotoxy(30,22);
  654.             clreol();
  655.             printf("Of %d cusps",*cusps);
  656.             gotoxy(30,23);
  657.             clreol();
  658.             printf("Is this ok (y/n) ?");
  659.             ch=getch();
  660.         }
  661.         if ( (ch=='y')||(ch=='Y')  )
  662.             break;
  663.         else  {
  664.                 ch =  'x';
  665.                 *cycloid  = 'x';
  666.                 *cusps    =  0;
  667.         }
  668.     }
  669.     while (!(OFF==ON));
  670.     clrscr();
  671. }
  672.  
  673.  
  674. void get_params2(float *power)
  675. {
  676.     char ch = 'x';
  677.     restorecrtmode();
  678.     clrscr();
  679.     gotoxy(0,4);
  680.     printf
  681.         ("To make a graph of a circle:  Radius squared = x squared + y squared\n"
  682.         "         or  R^2  =  X^2   +  Y^2 \n"
  683.         "However, when the exponent is other than 2 distortions occur.\n"
  684.         "You may enter a positive number for the exponent and observe that,\n"
  685.         "the closer the exponent is to zero, the more nearly crossed lines are drawn\n"
  686.         "while the larger the exponent, the more nearly tha graph approaches a square\n"
  687.         "In all cases the 'radius' is constant and represents the furthest distance\n"
  688.         "from the center");
  689.  
  690.     *power  = -1;
  691.     do         {
  692.         while (!((*power > 0 ))) {
  693.             gotoxy(30,15);
  694.             clreol();
  695.             printf("The power must be > 0");
  696.             gotoxy(30,16);
  697.             clreol();
  698.             printf("What should the power be?  ");
  699.             scanf("%f",power);
  700.         }
  701.  
  702.         while (!( ((ch=='y') || (ch=='Y'))||((ch=='n')||(ch=='N'))))  {
  703.             gotoxy(30,20);
  704.             clreol();
  705.             printf("The power  is: %f", *power );
  706.             gotoxy(30,21);
  707.             clreol();
  708.             printf("Is this ok (y/n) ?");
  709.             ch=getch();
  710.         }
  711.         if ( (ch=='y')||(ch=='Y')  )
  712.             break;
  713.         else  {
  714.             ch = 'x';
  715.             *power  = -1;
  716.         }
  717.     }
  718.     while (1);
  719.     clrscr();
  720. }
  721.  
  722.  
  723. void circloid()          {
  724.     float power;
  725.     int mode, x_out, y_out, again;
  726.     mode = getgraphmode();
  727.     setgraphmode( mode );
  728.     get_params2(&power);
  729.     setgraphmode( mode );
  730.     MainWindow( "Modifications of a Circle" );
  731.     StatusLine( "Return quits" );
  732.     settextjustify(LEFT_TEXT, TOP_TEXT);
  733.     ctr_graph_plot();
  734.     again = 'y';
  735.     while ( again == 'y' || again == 'Y') {
  736.         draw_circleoid(&x_out, &y_out, &power);
  737.         if  ( kbhit())   break;
  738.         again = getche() ;
  739.     }
  740. }
  741.  
  742.  
  743.  
  744. void asteroid()          {
  745.  
  746.     double z,zz,dblradius;
  747.     int mode,again,x1,x2,y1,y2,x_cusp,y_cusp,radius,color;
  748.  
  749.     mode = getgraphmode();
  750.     setgraphmode( mode );
  751.  
  752.     again = 'y';
  753.     while ( again == 'y' || again == 'Y') {
  754.         if  ( kbhit())   break;
  755.  
  756.         MainWindow( "Asteroid" );
  757.         StatusLine( "Return Advances" );
  758.           color=MaxColors-3;
  759.         setcolor(color);
  760.         radius = 80;
  761.         for(z=0;z<=radius;z+=4){
  762.             if  ( kbhit())   break;
  763.             x1 = CTR_X_ORIGIN - z;
  764.             x2 = CTR_X_ORIGIN + z;
  765.             y1 = CTR_Y_ORIGIN - (CTR_Y_ORIGIN  - z);
  766.             y2 = CTR_Y_ORIGIN + (CTR_Y_ORIGIN  - z);
  767.             line(x1, CTR_Y_ORIGIN, CTR_X_ORIGIN, y1);
  768.             line(x1, CTR_Y_ORIGIN, CTR_X_ORIGIN, y2);
  769.             line(x2, CTR_Y_ORIGIN, CTR_X_ORIGIN, y1);
  770.             line(x2, CTR_Y_ORIGIN, CTR_X_ORIGIN, y2);
  771.         }
  772.         again = getche() ;
  773.  
  774.         MainWindow( "Nephroid" );
  775.           StatusLine( "Return Advances" );
  776.         dblradius = 50;
  777.           color =  MaxColors - 2;
  778.           setcolor(color);
  779.           circle(CTR_X_ORIGIN, CTR_Y_ORIGIN, (int)dblradius);
  780.           color =  MaxColors - 3;
  781.           setcolor(color);
  782.         for(z=0;z <= PI/2; z+=.15){
  783.             x1 = CTR_X_ORIGIN + (int)(dblradius * (cos(z)));
  784.             x2 = CTR_X_ORIGIN - (int)(dblradius * (cos(z)));
  785.             y1 = CTR_Y_ORIGIN - (int)(dblradius * (sin(z)));
  786.             y2 = CTR_Y_ORIGIN + (int)(dblradius * (sin(z)));
  787.             circle(x1, y1, (int)(dblradius * (cos(z))));
  788.             circle(x2, y1, (int)(dblradius * (cos(z))));
  789.             circle(x2, y2, (int)(dblradius * (cos(z))));
  790.             circle(x1, y2, (int)(dblradius * (cos(z))));
  791.         }
  792.         again = getch();
  793.  
  794.  
  795.         MainWindow( "Cardioid" );
  796.         StatusLine( "Return Advances" );
  797.         dblradius = 25;
  798.           color =  MaxColors - 2;
  799.           setcolor(color);
  800.           circle(CTR_X_ORIGIN, CTR_Y_ORIGIN, (int)dblradius);
  801.           color =  MaxColors - 3;
  802.         setcolor(color);
  803.         x_cusp = CTR_X_ORIGIN - (int)dblradius;
  804.         y_cusp = CTR_Y_ORIGIN;
  805.         for(z=0;z <= PI/2; z+=.15){
  806.             x1 = CTR_X_ORIGIN + (int)(dblradius * (cos(z)));
  807.             x2 = CTR_X_ORIGIN - (int)(dblradius * (cos(z)));
  808.             y1 = CTR_Y_ORIGIN - (int)(dblradius * (sin(z)));
  809.             y2 = CTR_Y_ORIGIN + (int)(dblradius * (sin(z)));
  810.             circle(x1, y1,
  811.             (int)sqrt(((abs(x1)-abs(x_cusp))*(abs(x1)-abs(x_cusp))) +
  812.                 ((abs(y1)-abs(y_cusp))*(abs(y1)-abs(y_cusp)))));
  813.             circle(x2, y1,
  814.             (int)sqrt(((abs(x2)-abs(x_cusp))*(abs(x2)-abs(x_cusp))) +
  815.                 ((abs(y1)-abs(y_cusp))*(abs(y1)-abs(y_cusp)))));
  816.             circle(x2, y2,
  817.             (int)sqrt(((abs(x2)-abs(x_cusp))*(abs(x2)-abs(x_cusp))) +
  818.                 ((abs(y2)-abs(y_cusp))*(abs(y2)-abs(y_cusp)))));
  819.             circle(x1, y2,
  820.             (int)sqrt(((abs(x1)-abs(x_cusp))*(abs(x1)-abs(x_cusp))) +
  821.                 ((abs(y2)-abs(y_cusp))*(abs(y2)-abs(y_cusp)))));
  822.         }
  823.         again = getch();
  824.  
  825.         MainWindow( "Limacon" );
  826.         StatusLine( "Return Advances" );
  827.         dblradius = 25;
  828.           color =  MaxColors - 2;
  829.           setcolor(color);
  830.           circle(CTR_X_ORIGIN, CTR_Y_ORIGIN, (int)dblradius);
  831.           color =  MaxColors - 3;
  832.           setcolor(color);
  833.         x_cusp = CTR_X_ORIGIN - 2*(int)dblradius ;
  834.         y_cusp = CTR_Y_ORIGIN;
  835.         for(z=0;z <= PI/2; z+=.15){
  836.             x1 = CTR_X_ORIGIN + (int)(dblradius * (cos(z)));
  837.             x2 = CTR_X_ORIGIN - (int)(dblradius * (cos(z)));
  838.             y1 = CTR_Y_ORIGIN - (int)(dblradius * (sin(z)));
  839.             y2 = CTR_Y_ORIGIN + (int)(dblradius * (sin(z)));
  840.             circle(x1, y1,
  841.             (int)sqrt(((abs(x1)-abs(x_cusp))*(abs(x1)-abs(x_cusp))) +
  842.                 ((abs(y1)-abs(y_cusp))*(abs(y1)-abs(y_cusp)))));
  843.             circle(x2, y1,
  844.             (int)sqrt(((abs(x2)-abs(x_cusp))*(abs(x2)-abs(x_cusp))) +
  845.                 ((abs(y1)-abs(y_cusp))*(abs(y1)-abs(y_cusp)))));
  846.             circle(x2, y2,
  847.             (int)sqrt(((abs(x2)-abs(x_cusp))*(abs(x2)-abs(x_cusp))) +
  848.                 ((abs(y2)-abs(y_cusp))*(abs(y2)-abs(y_cusp)))));
  849.             circle(x1, y2,
  850.             (int)sqrt(((abs(x1)-abs(x_cusp))*(abs(x1)-abs(x_cusp))) +
  851.                 ((abs(y2)-abs(y_cusp))*(abs(y2)-abs(y_cusp)))));
  852.         }
  853.  
  854.         again = getch();
  855.  
  856.     }
  857. }
  858.  
  859.  
  860. void cycloids()      {
  861.  
  862. int again,color,radius,displacement,startangle,
  863.      endangle,mode,x_offset,y_offset,delay,i;
  864. struct arccoordstype arcinfo;
  865.     mode = getgraphmode();
  866.     setgraphmode( mode );
  867.  
  868. delay = 10000;
  869. radius = 20;
  870. X_OFFSET = 10;  /* offset for abcissa  */
  871. x_offset = 5;   /* offset along abcissa */
  872. Y_OFFSET = 50;
  873. y_offset = 2;
  874.     again = 'y';
  875.     while ( again == 'y' || again == 'Y') {
  876.        startangle = 341;
  877.        endangle   = 340;
  878.         MainWindow( "Common Cycloid" );
  879.         StatusLine( "Return Advances" );
  880.         sw_graph_plot();
  881.            for (displacement = 0; displacement <=270; displacement += 10) {
  882.                 if  ( kbhit())   break;
  883.                color = MaxColors - 2;
  884.                 setcolor(color);
  885.            arc(X_OFFSET + x_offset + radius + displacement,
  886.                    SW_Y_ORIGIN - radius - y_offset,
  887.                    startangle -= 18,
  888.                    endangle -= 18,
  889.                    radius);
  890.            getarccoords(&arcinfo);
  891.         setcolor( MaxColors - 1 );  /* Set current color to white */
  892.            line(    X_OFFSET + x_offset + radius + displacement,
  893.                 SW_Y_ORIGIN - radius - y_offset,
  894.                 arcinfo.xstart,
  895.                 arcinfo.ystart);
  896.            for(i=0 ; i<delay; i++) {}
  897.                    color = OFF;
  898.                 setcolor(color);
  899.            line(    X_OFFSET + x_offset + radius + displacement,
  900.                 SW_Y_ORIGIN - radius - y_offset,
  901.                 arcinfo.xstart,
  902.                 arcinfo.ystart);
  903.                arc(X_OFFSET + x_offset + radius + displacement,
  904.                     SW_Y_ORIGIN - radius - y_offset,
  905.                    startangle,
  906.                    endangle,
  907.                     radius);
  908.             setcolor( MaxColors - 1 );  /* Set current color to white */
  909.            arc(X_OFFSET + x_offset + radius + displacement,
  910.                    SW_Y_ORIGIN - radius - y_offset,
  911.                    endangle -1,
  912.                    startangle,      /* put point                      */
  913.                    radius + 1);     /* outside circle won't get erased*/
  914.  
  915.     }
  916.        startangle = 341;
  917.        endangle   = 340;
  918.             setcolor( MaxColors - 1 );  /* Set current color to white */
  919.            for (displacement = 0; displacement <=270; displacement += 10) {
  920.                 if  ( kbhit())   break;
  921.            arc(X_OFFSET + x_offset + radius + displacement,
  922.                    SW_Y_ORIGIN - radius - y_offset,
  923.                    endangle -= 18,
  924.                    startangle-= 18,
  925.                    radius + 1);
  926.         }
  927.  
  928.                 again = getche() ;
  929.  
  930.         MainWindow( "Prolate Cycloid" );
  931.         StatusLine( "Return Advances" );
  932.         x_offset = radius/2 + 5;   /* offset along abcissa */
  933.         y_offset = radius/2 + 2;
  934.        startangle = 341;
  935.        endangle   = 340;
  936.         sw_graph_plot();
  937.            for (displacement = 0; displacement <=270; displacement += 10) {
  938.                 if  ( kbhit())   break;
  939.                color = MaxColors - 2;
  940.                 setcolor(color);
  941.            arc(X_OFFSET + x_offset + radius + displacement,
  942.                    SW_Y_ORIGIN - radius - y_offset,
  943.                    startangle -= 18,
  944.                    endangle -= 18,
  945.                    radius);
  946.                color = OFF;
  947.                 setcolor(color);
  948.            arc(X_OFFSET + x_offset + radius + displacement,
  949.                    SW_Y_ORIGIN - radius - y_offset,
  950.                    startangle -= 18,
  951.                    endangle -= 18,
  952.                    radius + radius/2);
  953.            getarccoords(&arcinfo);
  954.         setcolor( MaxColors - 1 );  /* Set current color to white */
  955.            line(X_OFFSET + x_offset + radius + displacement,
  956.                 SW_Y_ORIGIN - radius - y_offset,
  957.                 arcinfo.xstart,
  958.                 arcinfo.ystart);
  959.            for(i=0 ; i<delay; i++) {}
  960.                color = OFF;
  961.                 setcolor(color);
  962.            line(X_OFFSET + x_offset + radius + displacement,
  963.                 SW_Y_ORIGIN - radius - y_offset,
  964.                 arcinfo.xstart,
  965.                 arcinfo.ystart);
  966.            arc(X_OFFSET + x_offset + radius + displacement,
  967.                 SW_Y_ORIGIN - radius - y_offset,
  968.                 startangle,
  969.                 endangle,
  970.                 radius);
  971.         setcolor( MaxColors - 1 );  /* Set current color to white */
  972.            arc(X_OFFSET + x_offset + radius + displacement,
  973.                 SW_Y_ORIGIN - radius - y_offset,
  974.                 endangle -1,
  975.                 startangle,      /* put point                      */
  976.                 radius + radius/2);     /* outside circle won't get erased*/
  977.  
  978.     }
  979.        startangle = 341;
  980.        endangle   = 340;
  981.             setcolor( OFF);
  982.            for (displacement = 0; displacement <=270; displacement += 10) {
  983.                 if  ( kbhit())   break;
  984.            arc(X_OFFSET + x_offset + radius + displacement,
  985.                    SW_Y_ORIGIN - radius - y_offset,
  986.                    endangle -= 36 ,
  987.                    startangle-= 36,
  988.                    radius + radius/2);
  989.            getarccoords(&arcinfo);
  990.             putpixel(arcinfo.xstart,
  991.                 arcinfo.ystart,
  992.                 MaxColors-1);
  993.         }
  994.         again = getch();
  995.  
  996.         MainWindow( "Curtate Cycloid" );
  997.         StatusLine( "Return Advances" );
  998.         x_offset = 5;   /* offset along abcissa */
  999.         y_offset = 2;
  1000.        startangle = 341;
  1001.        endangle   = 340;
  1002.         sw_graph_plot();
  1003.            for (displacement = 0; displacement <=270; displacement += 10) {
  1004.                 if  ( kbhit())   break;
  1005.                color = MaxColors - 2;
  1006.                 setcolor(color);
  1007.            arc(X_OFFSET + x_offset + radius + displacement,
  1008.                    SW_Y_ORIGIN - radius - y_offset,
  1009.                    startangle -= 18,
  1010.                    endangle -= 18,
  1011.                    radius);
  1012.                color = OFF;
  1013.                 setcolor(color);
  1014.            arc(X_OFFSET + x_offset + radius + displacement,
  1015.                    SW_Y_ORIGIN - radius - y_offset,
  1016.                    startangle -= 18,
  1017.                    endangle -= 18,
  1018.                    radius/2);
  1019.            getarccoords(&arcinfo);
  1020.         setcolor( MaxColors - 1 );  /* Set current color to white */
  1021.            line(X_OFFSET + x_offset + radius + displacement,
  1022.                 SW_Y_ORIGIN - radius - y_offset,
  1023.                 arcinfo.xstart,
  1024.                 arcinfo.ystart);
  1025.            for(i=0 ; i<delay; i++) {}
  1026.                color = OFF;
  1027.                 setcolor(color);
  1028.            line(X_OFFSET + x_offset + radius + displacement,
  1029.                 SW_Y_ORIGIN - radius - y_offset,
  1030.                 arcinfo.xstart,
  1031.                 arcinfo.ystart);
  1032.            arc(X_OFFSET + x_offset + radius + displacement,
  1033.                 SW_Y_ORIGIN - radius - y_offset,
  1034.                 startangle,
  1035.                 endangle,
  1036.                 radius);
  1037.         setcolor( MaxColors - 1 );  /* Set current color to white */
  1038.            arc(X_OFFSET + x_offset + radius + displacement,
  1039.                 SW_Y_ORIGIN - radius - y_offset,
  1040.                 endangle -1,
  1041.                 startangle,      /* put point                      */
  1042.                 radius/2);     /* outside circle won't get erased*/
  1043.  
  1044.     }
  1045.        startangle = 341;
  1046.        endangle   = 340;
  1047.             setcolor( OFF);
  1048.            for (displacement = 0; displacement <=270; displacement += 10) {
  1049.                 if  ( kbhit())   break;
  1050.            arc(X_OFFSET + x_offset + radius + displacement,
  1051.                    SW_Y_ORIGIN - radius - y_offset,
  1052.                    endangle -= 36 ,
  1053.                    startangle-= 36,
  1054.                    radius/2);
  1055.            getarccoords(&arcinfo);
  1056.             putpixel(arcinfo.xstart,
  1057.                 arcinfo.ystart,
  1058.                 MaxColors-1);
  1059.         }
  1060.         again = getch();
  1061.     }
  1062. X_OFFSET = 0;
  1063. Y_OFFSET = 0;
  1064. }
  1065.  
  1066.  
  1067. void roulettes()          {
  1068.     char cycloid;
  1069.     int cusps,mode, x_out, y_out, again;
  1070.     mode = getgraphmode();
  1071.     setgraphmode( mode );
  1072.     again = 'y';
  1073.     while ( again == 'y' || again == 'Y') {
  1074.     get_params8(&cycloid, &cusps);
  1075.     setgraphmode( mode );
  1076.     MainWindow( "Roulettes" );
  1077.     StatusLine( "Return quits / 'y' Again" );
  1078.     settextjustify(LEFT_TEXT, TOP_TEXT);
  1079.     ctr_graph_plot();
  1080.     draw_roulette(&cycloid, &cusps);
  1081.     again = getche() ;
  1082.     }
  1083. }
  1084.  
  1085.  
  1086. void draw_roulette(char *cycloid, int *cusps)  {
  1087.     double t;
  1088.     float radius, x_range, y_range, x_pos, y_pos, y_neg;
  1089.     int x_plot, y_plot, x_plot_old, y_plot_old, x_scaled, y_scaled,
  1090.     x_out, y_out, color, size;
  1091.  
  1092.  
  1093.     radius = 5;
  1094.     x_out = 70;
  1095.     y_out = 10;
  1096.     x_range = radius * 15;
  1097.     y_range = radius * 15;
  1098.  
  1099.     x_plot_old = 0;
  1100.     y_plot_old = 0;
  1101.     size = 24/(*cusps);
  1102.     if ( size < 1) size = 1;
  1103.     if ((*cycloid=='E') || (*cycloid=='e'))
  1104.         if(size > 5) size = 6;
  1105.     setcolor( MaxColors - 1 );
  1106.       if ((*cycloid=='E') || (*cycloid=='e')) {
  1107.         if (*cusps == 1) {
  1108.             gprintf(&x_out,&y_out,"Epicycloid  %d cusp",*cusps);
  1109.         }
  1110.         else {
  1111.             gprintf(&x_out,&y_out," Epicycloid  %d cusps",*cusps);
  1112.         }
  1113.       *cusps += 1;
  1114.       }
  1115.       else  {
  1116.          if (*cusps == 1) {
  1117.             gprintf(&x_out,&y_out,"Hypocycloid  %d cusp",*cusps);
  1118.          }
  1119.         else {
  1120.             gprintf(&x_out,&y_out,"Hypocycloid  %d cusps",*cusps);
  1121.         }
  1122.         *cusps -= 1;
  1123.       }
  1124.     for ( t = 0; t <= 2*PI ; t += .02) {
  1125.       if  ( kbhit())   break;
  1126.       if ((*cycloid=='E') || (*cycloid=='e')) {
  1127.         x_pos = (*cusps * size * (float)cos(t)) - (size * (float)cos(*cusps * t));
  1128.         y_pos = (*cusps * size * (float)sin(t)) - (size * (float)sin(*cusps * t));
  1129.       }
  1130.       else {
  1131.         x_pos = (*cusps * size * (float)cos(t)) + (size * (float)cos(*cusps * t));
  1132.         y_pos = (*cusps * size * (float)sin(t)) - (size * (float)sin(*cusps * t));
  1133.      }
  1134.         x_scaled = scale_x(&x_pos, &x_range) ;
  1135.         y_scaled = scale_y(&y_pos, &y_range);
  1136.         x_plot = CTR_X_ORIGIN + x_scaled ;
  1137.         y_plot = CTR_Y_ORIGIN - y_scaled;
  1138.     setcolor( MaxColors - 2 );
  1139.     if (!(x_plot_old == 0)) line(x_plot_old,y_plot_old,x_plot,y_plot);
  1140.         x_plot_old = x_plot;
  1141.         y_plot_old = y_plot;
  1142.     }
  1143. }