0707070000020056001006440001460001440000010513350355636145300000500000000003Size90 0707070000020055631007770001460001440000010513400355447630600001100000000044MAKEcpiocat Files | cpio -ocBv > ROSESRC+IN 0707070000020053411007770001460001440000010513410355447630600001100000000044MAKEflopcat Files | cpio -ocBv > /dev/fp021 0707070000020055761006660001460001440000010513420355636024100001100000000601Makefileinclude $(MAKEINC)/Makepre.h all: rose rosea2 rosem2 rose: rose.o $(LD) $(LDFLAGS) $(SHAREDLIB) -o rose rose.o $(LIBM) /usr/lib/libcvdi.a rosea2: rosea2.o $(LD) $(LDFLAGS) $(SHAREDLIB) -o rosea2 rosea2.o $(LIBM) /usr/lib/libcvdi.a rosem2: rosem2.o $(LD) $(LDFLAGS) $(SHAREDLIB) -o rosem2 rosem2.o $(LIBM) /usr/lib/libcvdi.a include $(MAKEINC)/Makepost.h 0707070000020055701006660001460001440000010513430355636143500000500000000101NameROSESRC - Source and Docs for THE ROSE - 10/85 - from THE STORE! 0707070000020055651007770001460001440000010513440355447630700000700000000261RemoveNAME=ROSE FOLDER=/u/$LOGNAME/Filecabinet/SRC rm -rf ${FOLDER}/$NAME > /dev/null 2>&1 NAME=ROSE.DOC FOLDER=/u/$LOGNAME/Filecabinet/DOCS rm -rf ${FOLDER}/$NAME > /dev/null 2>&1 0707070000020055561006440001460001440000010513450355636151000000600000000164Files./Size ./MAKEcpio ./MAKEflop ./Makefile ./Name ./Remove ./Files ./Install ./rose.c ./ROSE.DOC ./rosea2.c ./rosem2.c 0707070000020056121007770001460001440000010437710355747553700001000000003134InstallNAME=ROSE FOLDER=/u/$LOGNAME/Filecabinet/SRC if [ -d $FOLDER ] then message -i "A new folder called $NAME will be created in your Filecabinet/SRC folder. The source code will be placed in this folder for your use.\n\nTouch to continue." else message -i "A folder called SRC is being created in your Filecabinet. A second folder called SRC/$NAME will then be created to hold the source code for your use.\n\nTouch to continue." mkdir $FOLDER chown $LOGNAME $FOLDER fi mkdir ${FOLDER}/$NAME chown $LOGNAME ${FOLDER}/$NAME DEST=${FOLDER}/$NAME for i in rose.c rosea2.c rosem2.c Makefile do ln $i ${DEST}/$i chown $LOGNAME ${DEST}/$i done message -i "OK - source is in Filecabinet/SRC/${NAME}.\n\nThere is a makefile along with one "C" source.\n\nThe source is called "rose.c".\n\nTouch to continue." FOLDER=/u/$LOGNAME/Filecabinet/DOCS if [ -d $FOLDER ] then message -i "A file called "ROSE.DOC" is being placed in your DOCS folder. This file contains interesting information about THE ROSE.\n\nTouch to continue." else message -i "A folder called DOCS is being created in your Filecabinet. A file called ROSE.DOC will then be placed in the folder. This file contains interesting information about THE ROSE.\n\nTouch to continue." mkdir $FOLDER chown $LOGNAME $FOLDER fi DEST=${FOLDER} for i in ROSE.DOC do ln $i ${DEST}/$i chown $LOGNAME ${DEST}/$i done message "Two final notes:\n1. The executables WILL NOT RUN without first installing the drivers that came with the Foundation Set (2 floppies).\n2. If running from the shell, set DISPLAY=pc7300 and export." 0707070000020056151006660001460001440000010515540355746557400000700000014337rose.c#include #include #define ldtor(x) ((float)(((((float)x)/sdiv)*2.0)*PI)) #define PI 3.1415926536 short work_in[19] = { 1, /* ndc index */ 1, /* polyline line type */ 1, /* polyline color index */ 1, /* polymarker type */ 1, /* polymarker color index */ 1, /* graphics text font */ 1, /* graphics text color index */ 1, /* fill interior style */ 1, /* fill style index */ 0, /* fill color index */ 1, /* display prompts */ 'D', 'I', 'S', 'P', 'L', 'A', 'Y', ' ', /* device name */ }; short dev_handle; short work_out[66]; short pa[4]; short lobox[4]; short attrib[10]; short x_out,y_out; short xnum[3]; int ynum[3]; short echo_xy[2] = { 0 , 0 }; main(argc,argv) int argc; char *argv[]; { int t, tt, tl, dt, lp, x; float r; float oldx, oldy, newx, newy; float offx, offy; FILE *numfil; float vx,vy; float mxy; int typ; char c[2]; int dparm; char otarget[500]; float sdiv = 360.0; int isdiv = 360; short rv,rc; int keyget; int done = 0; int rvl; int x_pref,y_pref; int dosig(); keyget = 0; dparm = 0; xnum[0] = 4368; xnum[1] = 2391; xnum[2] = 1031; numfil=fopen("/usr/games/rose.rand","r"); if (numfil != NULL) { fscanf(numfil,"%d %d %d",&ynum[0],&ynum[1],&ynum[2]); xnum[0] = ynum[0]; xnum[1] = ynum[1]; xnum[2] = ynum[2]; fclose(numfil); } rv = v_opnwk(work_in,&dev_handle,work_out); if (rv != 0) { fprintf(stderr,"vq_error=%d\n",vq_error()); exit(100); } vqt_attributes(dev_handle,attrib); lobox[0] = 0; lobox[1] = 0; lobox[2] = work_out[51]; lobox[3] = attrib[9]; v_clrwk(dev_handle); vx = work_out[51]; vy = work_out[52]; if (vx 0) { if (c[0]=='q') { done = 1; break; } else if (c[0]=='a') { keyget = 1; } else if (c[0]=='c') { keyget = 0; } else if (c[0]=='o') { dparm = 1; } else if (c[0]=='p') { v_bar(dev_handle,lobox); dparm = 0; } else if (c[0]=='k') { sprintf(otarget,"Enter new subdivision value (Current value is %d)",isdiv); readval(otarget,&rvl); if (rvl > 0) { isdiv = rvl; sdiv = isdiv; } } else if (c[0]=='h') { help(); } rc = vsm_string(dev_handle,(short)1,(short)0,echo_xy,c); } if (done) { break; } if (keyget) { readval("Enter loop count",&rvl); if (rvl > 0) { lp = rvl; } readval("Enter delta",&rvl); if (rvl > 0) { dt = rvl; } } if (dparm) { sprintf(otarget,"loops=%d,delta=%d",lp,dt); vsa_position(dev_handle,(short)0,(short)0,&x_out,&y_out); v_bar(dev_handle,lobox); v_atext(dev_handle,otarget,&x_out,&y_out); } t=0; tt=0; tl = 0; oldx = offx = mxy/2; oldy = offy = mxy/2; /* draw rose */ while (tl < sdiv) { t = tt; do { tl++; t=(t+dt)%isdiv; x=(lp*t)%isdiv; r = sin(ldtor(x))*mxy; newx = offx + ((r*cos(ldtor(t)))/2.0); newy = offy + ((r*sin(ldtor(t)))/2.0); pa[0] = oldx + x_pref; pa[1] = oldy + y_pref; pa[2] = newx + x_pref; pa[3] = newy + y_pref; v_pline(dev_handle,2,pa); oldx=newx; oldy=newy; } while ( t != tt ) ; tt++; x=(lp*tt)%isdiv; r = sin(ldtor(x))*mxy; oldx = offx + ((r*cos(ldtor(tt)))/2.0); oldy = offy + ((r*sin(ldtor(tt)))/2.0); } numfil = fopen("/usr/games/rose.rand","w"); if (numfil != NULL) { ynum[0] = xnum[0]; ynum[1] = xnum[1]; ynum[2] = xnum[2]; fprintf(numfil,"%d %d %d\n",ynum[0],ynum[1],ynum[2]); fclose(numfil); } sleep(5); } v_clswk(dev_handle); } readval(is,oi) char *is; int *oi; { char os[101]; v_bar(dev_handle,lobox); vsa_position(dev_handle,(short)0,(short)0,&x_out,&y_out); v_atext(dev_handle,is,&x_out,&y_out); v_atext(dev_handle,": ",&x_out,&y_out); echo_xy[0] = x_out; echo_xy[1] = y_out+100; vrq_string(dev_handle,(short)100,(short)1,echo_xy,os); *oi = atoi(os); } displ(is) char *is; { v_bar(dev_handle,lobox); vsa_position(dev_handle,(short)0,(short)0,&x_out,&y_out); v_atext(dev_handle,is,&x_out,&y_out); } help() { char c[2],tc; v_clrwk(dev_handle); vsa_position(dev_handle,(short)0,(short)(work_out[52]+attrib[9]), &x_out,&y_out); v_atext(dev_handle,"\nROSE HELP\r\n\n",&x_out,&y_out); v_atext(dev_handle,"This program inscribes a polygon inside of the\r\n",&x_out,&y_out); v_atext(dev_handle,"polar coordinate figure r=sin(n*theta) by connecting each ith point on the curve.\r\n",&x_out,&y_out); v_atext(dev_handle,"By default there are 360 plotting points, but you can change this.\r\n",&x_out,&y_out); v_atext(dev_handle,"By default n (the loop count) and i (the delta) are chosen randomly.\r\n",&x_out,&y_out); v_atext(dev_handle,"If you wish, you may specify n and i for each figure.\r\n\n",&x_out,&y_out); v_atext(dev_handle,"type one or more of the following letters while a figure is being drawn:\r\n\n",&x_out,&y_out); v_atext(dev_handle,"\r\n\n",&x_out,&y_out); v_atext(dev_handle,"a - ask for loop and delta values\r\n",&x_out,&y_out); v_atext(dev_handle,"c - generate loop and delta values randomly (default)\r\n",&x_out,&y_out); v_atext(dev_handle,"o - display loop and delta values for each figure\r\n",&x_out,&y_out); v_atext(dev_handle,"p - do not display loop and delta values (default)\r\n",&x_out,&y_out); v_atext(dev_handle,"k - change the number of circle subdivisions (default 360)\r\n",&x_out,&y_out); v_atext(dev_handle,"q - quit\r\n",&x_out,&y_out); v_atext(dev_handle,"h - display this menu\r\n",&x_out,&y_out); displ("Press any key to continue"); vrq_string(dev_handle,(short)1,(short)0,echo_xy,c); v_clrwk(dev_handle); } 0707070000020056041006660001460001440000010513570355447631200001100000040672ROSE.DOC - 1 - Dear Rose User: You have probably had fun watching THE ROSE demo on your 7300. If not, you should probably take time now to do so. This letter is designed to enhance your enjoyment of the program by explaining some of its mathematical properties. Originally, the "rose" program was one of the standard "blit" demos. The original program displays polygons inscribed in n-petal roses using the following algorithm: 1. Obtain integer values for n and d such that 1_360 replace T by the remainder obtained when dividing T by 360. (That is, reduce mod 360). 4. Compute nT, reduce it mod 360, convert the result from degrees to radians, and set x equal to the final result. 5. Set r equal to the sin of x. 6. Convert the point (T,r) from polar to rectangular coordinates to obtain the point (newx,newy). 7. Draw a line from (oldx,oldy) to (newx,newy). 8. If T is equal to zero then stop, else set (oldx,oldy) to (newx,newy) and go back to step 3. Simply stated, the program starts with the basic figure defined by the polar equation r=sin(nT), and connects every dth point (out of 360 potential sampling points) along the edge of the curve. The basic figure is a 2n-petaled rose, (if n is odd, half of the petals are superimposed on the other half to give the appearance of n petals). The values for n and d are chosen a random number generator (the "c" command), or specified by the user (the "a" command). In the original algorithm the number of edges in the generated polygon depends on the gcd of the delta (value of d) and 360. If the gcd of d and 360 is k then the polygon will have 360/k edges. Some, or all of these edges may be degenerate (starting and ending points coincide). For the smaller values of n, one can generate a picture of the underlying curve by selecting a delta of 1. The edges are so short, that they are essentially points and the angles between the lines appear to smooth out. You can try this using the "a" command of THE ROSE. Since 360 has a lot of divisors, there are a lot of numbers which produce fewer than the maximum number of edges using the original algorithm. In fact far too many of the figures contain only a few lines, or, even worse, just a dot in the middle of the screen. In order to increase the density of - 2 - the figures, I modified the algorithm so it would always draw 360 lines. I did this by counting the number of lines generated by the main loop of the algorithm, and if the number of lines was less than 360, I added 1 to the initial starting point of the algorithm (which _w_a_s T=0) and generated lines until T returned to its starting value. This is the modified algorithm: 1. Obtain integer values for n and d such that 1_360 replace T by the remainder obtained when dividing T by 360. 4. Compute nT, reduce it mod 360, convert the result from degrees to radians, and set x equal to the final result. 5. Set r equal to the sin of x. 6. Convert the point (T,r) from polar to rectangular coordinates to obtain the point (newx,newy). 7. Draw a line from (oldx,oldy) to (newx,newy). 7a. Add 1 to c. 8. If T is equal to T then go to step 8a, else set (oldx,oldy) to (newx,newy) and go back to step 3. 8a. If c_>360 stop, else add 1 to T and go back to step 2. With this modification, it is possible to study the evolution of a figure with a fixed value of n, as the delta increased. (This was possible before, but you had to be careful to avoid degenerate figures.) Using the "a" command of THE ROSE, you should try n=2 for d=15,30,45,...15n,... As you will see, the line of the figure becomes fatter and more filigreed until the space between the loops disappears. At the same time a squarish figure appears in the center (the shape, of course depends on n). Eventually the squarish figure grows until it overwhelms the entire figure leaving holes for the original petals. Then the petals become more "hairy" looking and the squarish shape begins to degenerate into filigree between the petals, until the shape disappears entirely leaving only the hairy petals. This form of evolution takes place (at different rates) for all figures with small n. As interesting as this evolution is, it is a trivial phenomenon compared to some of the other things the program will do. I had assumed that the reason than n was restricted to the range [1,32] in the original algorithm, is that as n becomes very large, the polygon degenerates into a bunch of random lines. In fact some experiments I did with - 3 - n in the high twenties and low thirties seemed to bear that out. But just to make sure, I tried a few figures with very large n. To my surprise, the figures did _n_o_t degenerate into random lines, but instead became even more complicated and beautiful than their low-n counterparts. I was particularly fascinated by the two circles generated when n=181 and d=2 as well as the four circles generated when n=91 and d=4. I could see from the way that other figures were being drawn that they consisted of several copies of the low-n figures rotated different distances about the origin. I developed and proved the following theorem to explain this phenomenon. I call this theorem the _z_e_r_o+ theorem because it involves adding an integer to a zero- divisor in the ring of integers mod 360. The _z_e_r_o+ theorem: Let the sin function be evaluated in degrees and let the points (T,sin(T)) represent the angle and radius of points in the usual polar coordinate system. Suppose that T, k, n, and m are integers and that nm = 360. if T is of the form mj+i where i and j are integers, then the point (T,sin((n+k)T)) is on the curve defined by (T,sin(kT)) rotated ni degrees clockwise about the origin. proof: sin((n+k)T)= sin(nT+kT) let T=mj+i then sin(nT+kT)= sin(n(mj+i)+kT)= sin(nmj+ni+kT)= sin(360j+ni+kT)= sin(ni+kT) (because sin(kT+ni) is periodic in 360.) Note that the value of ni is a constant which does not depend on T. let u=kT then sin(kT)= sin(u) rotating sin(u) ni degrees clockwise (in the negative T direction) about the origin we get: sin(u+ni)= sin(ni+kT) Note that it is the underlying curve which is rotated ni degrees, not the plotting points themselves. The plotting points are moved ni degrees forward along the underlying curve's graph for each successive figure. For certain - 4 - values of n and d, this produces a stunning effect when the figure is drawn. For example when the polygon for n=5+1=6 and d=72 is drawn, you will see a rotating pentangle which eventually produces a figure which looks nothing like a pentangle (try it). (The explanation for the rotating pentangle is left as an exercise.) The _z_e_r_o+ theorem explains why n=91 and d=4 produces four interlocking circles. Since n=90+1, the plotting points lie on four circles, (the curve defined by r=sin(T)), rotated 0, 90, 180, and 270 degrees.) With a delta of 4, the program will first plot all points for T=4k then all points with T=4k+1, and so forth. Since, in this case, the values x, 4+x, 8+x, produce successive points along the rotated curve, and since the points are close together, circles are drawn. (I don't know when the points are successive and when they are not. The rotating pentangle shows that they aren't always.) The _z_e_r_o+ theorem can be extended to negative offsets from zero-divisors by observing that the graph of r=sin((-n)T) is identical to the graph of r=sin(nT) rotated 180 degrees about the origin. (Proof: sin((-n)T) = sin(-(nT)) = sin((nT)-180).) One consequence of the _z_e_r_o+ theorem is that the figures for n_>360 are identical to those for 0_ #include #define ldtor(x) ((float)(((((float)x)/sdiv)*2.0)*PI)) #define PI 3.1415926536 short work_in[19] = { 1, /* ndc index */ 1, /* polyline line type */ 1, /* polyline color index */ 1, /* polymarker type */ 1, /* polymarker color index */ 1, /* graphics text font */ 1, /* graphics text color index */ 1, /* fill interior style */ 1, /* fill style index */ 0, /* fill color index */ 1, /* display prompts */ 'D', 'I', 'S', 'P', 'L', 'A', 'Y', ' ', /* device name */ }; short dev_handle; short work_out[66]; short pa[4]; short lobox[4]; short attrib[10]; short x_out,y_out; short xnum[3]; int ynum[3]; short echo_xy[2] = { 0 , 0 }; main(argc,argv) int argc; char *argv[]; { int t, tt, tl, dt, lp1, lp2, x1, x2; float r; float oldx, oldy, newx, newy; float offx, offy; FILE *numfil; float vx,vy; float mxy; int typ; char c[2]; int dparm; char otarget[500]; float sdiv = 360.0; int isdiv = 360; short rv,rc; int keyget; int done = 0; int rvl; int x_pref,y_pref; int dosig(); keyget = 0; dparm = 0; xnum[0] = 4368; xnum[1] = 2391; xnum[2] = 1031; numfil=fopen("/usr/games/rose.rand","r"); if (numfil != NULL) { fscanf(numfil,"%d %d %d",&ynum[0],&ynum[1],&ynum[2]); xnum[0] = ynum[0]; xnum[1] = ynum[1]; xnum[2] = ynum[2]; fclose(numfil); } rv = v_opnwk(work_in,&dev_handle,work_out); if (rv != 0) { fprintf(stderr,"vq_error=%d\n",vq_error()); exit(100); } vqt_attributes(dev_handle,attrib); lobox[0] = 0; lobox[1] = 0; lobox[2] = work_out[51]; lobox[3] = attrib[9]; v_clrwk(dev_handle); vx = work_out[51]; vy = work_out[52]; if (vx 0) { if (c[0]=='q') { done = 1; break; } else if (c[0]=='a') { keyget = 1; } else if (c[0]=='c') { keyget = 0; } else if (c[0]=='o') { dparm = 1; } else if (c[0]=='p') { v_bar(dev_handle,lobox); dparm = 0; } else if (c[0]=='k') { sprintf(otarget,"Enter new subdivision value (Current value is %d)",isdiv); readval(otarget,&rvl); if (rvl > 0) { isdiv = rvl; sdiv = isdiv; } } else if (c[0]=='h') { help(); } rc = vsm_string(dev_handle,(short)1,(short)0,echo_xy,c); } if (done) { break; } if (keyget) { readval("Enter loop count 1",&rvl); if (rvl > 0) { lp1 = rvl; } readval("Enter loop count 2",&rvl); if (rvl > 0) { lp2 = rvl; } readval("Enter delta",&rvl); if (rvl > 0) { dt = rvl; } } if (dparm) { sprintf(otarget,"lp1=%d,lp2=%d,delta=%d",lp1,lp2,dt); vsa_position(dev_handle,(short)0,(short)0,&x_out,&y_out); v_bar(dev_handle,lobox); v_atext(dev_handle,otarget,&x_out,&y_out); } t=0; tt=0; tl = 0; oldx = offx = mxy/2; oldy = offy = mxy/2; /* draw rose */ while (tl < sdiv) { t = tt; do { tl++; t=(t+dt)%isdiv; x1=(lp1*t)%isdiv; x2=(lp2*t)%isdiv; r = ((sin(ldtor(x1))+sin(ldtor(x2)))/2.0)*mxy; newx = offx + ((r*cos(ldtor(t)))/2.0); newy = offy + ((r*sin(ldtor(t)))/2.0); pa[0] = oldx + x_pref; pa[1] = oldy + y_pref; pa[2] = newx + x_pref; pa[3] = newy + y_pref; v_pline(dev_handle,2,pa); oldx=newx; oldy=newy; } while ( t != tt ) ; tt++; x1=(lp1*tt)%isdiv; x2=(lp2*tt)%isdiv; r = ((sin(ldtor(x1))+sin(ldtor(x2)))/2.0)*mxy; oldx = offx + ((r*cos(ldtor(tt)))/2.0); oldy = offy + ((r*sin(ldtor(tt)))/2.0); } numfil = fopen("/usr/games/rose.rand","w"); if (numfil != NULL) { ynum[0] = xnum[0]; ynum[1] = xnum[1]; ynum[2] = xnum[2]; fprintf(numfil,"%d %d %d\n",ynum[0],ynum[1],ynum[2]); fclose(numfil); } sleep(5); } v_clswk(dev_handle); } readval(is,oi) char *is; int *oi; { char os[101]; v_bar(dev_handle,lobox); vsa_position(dev_handle,(short)0,(short)0,&x_out,&y_out); v_atext(dev_handle,is,&x_out,&y_out); v_atext(dev_handle,": ",&x_out,&y_out); echo_xy[0] = x_out; echo_xy[1] = y_out+100; vrq_string(dev_handle,(short)100,(short)1,echo_xy,os); *oi = atoi(os); } displ(is) char *is; { v_bar(dev_handle,lobox); vsa_position(dev_handle,(short)0,(short)0,&x_out,&y_out); v_atext(dev_handle,is,&x_out,&y_out); } help() { char c[2],tc; v_clrwk(dev_handle); vsa_position(dev_handle,(short)0,(short)(work_out[52]+attrib[9]), &x_out,&y_out); v_atext(dev_handle,"\nSUM OF TWO ROSES, HELP\r\n\n",&x_out,&y_out); v_atext(dev_handle,"This program inscribes a polygon inside of the\r\n",&x_out,&y_out); v_atext(dev_handle,"polar coordinate figure r=sin(n1*theta)+sin(n2*theta) by connecting each ith point\r\n",&x_out,&y_out); v_atext(dev_handle,"on the curve. By default there are 360 plotting points, but you can change this.\r\n",&x_out,&y_out); v_atext(dev_handle,"By default n1, n2, (the loop counts) and i (the delta) are chosen randomly.\r\n",&x_out,&y_out); v_atext(dev_handle,"If you wish, you may specify n1, n2, and i for each figure.\r\n\n",&x_out,&y_out); v_atext(dev_handle,"type one or more of the following letters while a figure is being drawn:\r\n\n",&x_out,&y_out); v_atext(dev_handle,"\r\n\n",&x_out,&y_out); v_atext(dev_handle,"a - ask for loop and delta values\r\n",&x_out,&y_out); v_atext(dev_handle,"c - generate loop and delta values randomly (default)\r\n",&x_out,&y_out); v_atext(dev_handle,"o - display loop and delta values for each figure\r\n",&x_out,&y_out); v_atext(dev_handle,"p - do not display loop and delta values (default)\r\n",&x_out,&y_out); v_atext(dev_handle,"k - change the number of circle subdivisions (default 360)\r\n",&x_out,&y_out); v_atext(dev_handle,"q - quit\r\n",&x_out,&y_out); v_atext(dev_handle,"h - display this menu\r\n",&x_out,&y_out); displ("Press any key to continue"); vrq_string(dev_handle,(short)1,(short)0,echo_xy,c); v_clrwk(dev_handle); } 0707070000020056061006660001460001440000010514100355636025200001100000015002rosem2.c#include #include #define ldtor(x) ((float)(((((float)x)/sdiv)*2.0)*PI)) #define PI 3.1415926536 short work_in[19] = { 1, /* ndc index */ 1, /* polyline line type */ 1, /* polyline color index */ 1, /* polymarker type */ 1, /* polymarker color index */ 1, /* graphics text font */ 1, /* graphics text color index */ 1, /* fill interior style */ 1, /* fill style index */ 0, /* fill color index */ 1, /* display prompts */ 'D', 'I', 'S', 'P', 'L', 'A', 'Y', ' ', /* device name */ }; short dev_handle; short work_out[66]; short pa[4]; short lobox[4]; short attrib[10]; short x_out,y_out; short xnum[3]; int ynum[3]; short echo_xy[2] = { 0 , 0 }; main(argc,argv) int argc; char *argv[]; { int t, tt, tl, dt, lp1, lp2, x1, x2; float r; float oldx, oldy, newx, newy; float offx, offy; FILE *numfil; float vx,vy; float mxy; int typ; char c[2]; int dparm; char otarget[500]; float sdiv = 360.0; int isdiv = 360; short rv,rc; int keyget; int done = 0; int rvl; int x_pref,y_pref; int dosig(); keyget = 0; dparm = 0; xnum[0] = 4368; xnum[1] = 2391; xnum[2] = 1031; numfil=fopen("/usr/games/rose.rand","r"); if (numfil != NULL) { fscanf(numfil,"%d %d %d",&ynum[0],&ynum[1],&ynum[2]); xnum[0] = ynum[0]; xnum[1] = ynum[1]; xnum[2] = ynum[2]; fclose(numfil); } rv = v_opnwk(work_in,&dev_handle,work_out); if (rv != 0) { fprintf(stderr,"vq_error=%d\n",vq_error()); exit(100); } vqt_attributes(dev_handle,attrib); lobox[0] = 0; lobox[1] = 0; lobox[2] = work_out[51]; lobox[3] = attrib[9]; v_clrwk(dev_handle); vx = work_out[51]; vy = work_out[52]; if (vx 0) { if (c[0]=='q') { done = 1; break; } else if (c[0]=='a') { keyget = 1; } else if (c[0]=='c') { keyget = 0; } else if (c[0]=='o') { dparm = 1; } else if (c[0]=='p') { v_bar(dev_handle,lobox); dparm = 0; } else if (c[0]=='k') { sprintf(otarget,"Enter new subdivision value (Current value is %d)",isdiv); readval(otarget,&rvl); if (rvl > 0) { isdiv = rvl; sdiv = isdiv; } } else if (c[0]=='h') { help(); } rc = vsm_string(dev_handle,(short)1,(short)0,echo_xy,c); } if (done) { break; } if (keyget) { readval("Enter loop count 1",&rvl); if (rvl > 0) { lp1 = rvl; } readval("Enter loop count 2",&rvl); if (rvl > 0) { lp2 = rvl; } readval("Enter delta",&rvl); if (rvl > 0) { dt = rvl; } } if (dparm) { sprintf(otarget,"lp1=%d,lp2=%d,delta=%d",lp1,lp2,dt); vsa_position(dev_handle,(short)0,(short)0,&x_out,&y_out); v_bar(dev_handle,lobox); v_atext(dev_handle,otarget,&x_out,&y_out); } t=0; tt=0; tl = 0; oldx = offx = mxy/2; oldy = offy = mxy/2; /* draw rose */ while (tl < sdiv) { t = tt; do { tl++; t=(t+dt)%isdiv; x1=(lp1*t)%isdiv; x2=(lp2*t)%isdiv; r = ((sin(ldtor(x1))*sin(ldtor(x2))))*mxy; newx = offx + ((r*cos(ldtor(t)))/2.0); newy = offy + ((r*sin(ldtor(t)))/2.0); pa[0] = oldx + x_pref; pa[1] = oldy + y_pref; pa[2] = newx + x_pref; pa[3] = newy + y_pref; v_pline(dev_handle,2,pa); oldx=newx; oldy=newy; } while ( t != tt ) ; tt++; x1=(lp1*tt)%isdiv; x2=(lp2*tt)%isdiv; r = ((sin(ldtor(x1))*sin(ldtor(x2))))*mxy; oldx = offx + ((r*cos(ldtor(tt)))/2.0); oldy = offy + ((r*sin(ldtor(tt)))/2.0); } numfil = fopen("/usr/games/rose.rand","w"); if (numfil != NULL) { ynum[0] = xnum[0]; ynum[1] = xnum[1]; ynum[2] = xnum[2]; fprintf(numfil,"%d %d %d\n",ynum[0],ynum[1],ynum[2]); fclose(numfil); } sleep(5); } v_clswk(dev_handle); } readval(is,oi) char *is; int *oi; { char os[101]; v_bar(dev_handle,lobox); vsa_position(dev_handle,(short)0,(short)0,&x_out,&y_out); v_atext(dev_handle,is,&x_out,&y_out); v_atext(dev_handle,": ",&x_out,&y_out); echo_xy[0] = x_out; echo_xy[1] = y_out+100; vrq_string(dev_handle,(short)100,(short)1,echo_xy,os); *oi = atoi(os); } displ(is) char *is; { v_bar(dev_handle,lobox); vsa_position(dev_handle,(short)0,(short)0,&x_out,&y_out); v_atext(dev_handle,is,&x_out,&y_out); } help() { char c[2],tc; v_clrwk(dev_handle); vsa_position(dev_handle,(short)0,(short)(work_out[52]+attrib[9]), &x_out,&y_out); v_atext(dev_handle,"\nPRODUCT OF TWO ROSES, HELP\r\n\n",&x_out,&y_out); v_atext(dev_handle,"This program inscribes a polygon inside of the\r\n",&x_out,&y_out); v_atext(dev_handle,"polar coordinate figure r=sin(n1*theta)*sin(n2*theta) by connecting each ith point\r\n",&x_out,&y_out); v_atext(dev_handle,"on the curve. By default there are 360 plotting points, but you can change this.\r\n",&x_out,&y_out); v_atext(dev_handle,"By default n1, n2, (the loop counts) and i (the delta) are chosen randomly.\r\n",&x_out,&y_out); v_atext(dev_handle,"If you wish, you may specify n1, n2, and i for each figure.\r\n\n",&x_out,&y_out); v_atext(dev_handle,"type one or more of the following letters while a figure is being drawn:\r\n\n",&x_out,&y_out); v_atext(dev_handle,"\r\n\n",&x_out,&y_out); v_atext(dev_handle,"a - ask for loop and delta values\r\n",&x_out,&y_out); v_atext(dev_handle,"c - generate loop and delta values randomly (default)\r\n",&x_out,&y_out); v_atext(dev_handle,"o - display loop and delta values for each figure\r\n",&x_out,&y_out); v_atext(dev_handle,"p - do not display loop and delta values (default)\r\n",&x_out,&y_out); v_atext(dev_handle,"k - change the number of circle subdivisions (default 360)\r\n",&x_out,&y_out); v_atext(dev_handle,"q - quit\r\n",&x_out,&y_out); v_atext(dev_handle,"h - display this menu\r\n",&x_out,&y_out); displ("Press any key to continue"); vrq_string(dev_handle,(short)1,(short)0,echo_xy,c); v_clrwk(dev_handle); } 0707070000020056061006660001460001440000010514100355636025200001300000000000TRAILER!!!,lobox); dparm = 0; } else if (c[0]=='k') { sprintf(otarget,"Enter new subdivision value (Current value is %d)",isdiv); readval(otarget,&rvl); if (rvl > 0) { isdiv = rvl; sdiv = isdiv; } } else if (c[0]=='h') { help(); } rc = vsm_string(dev_handle,(short)1,(short)0,echo_xy,c); } if (done) { break; } if (keyget) { readval("Enter loop count 1",&rvl); if (rvl > 0) { lp1 = rvl; } readval("Enter loop count 2",&rvl); if (rvl > 0) { lp2 = rvl; } readval("Enter delta",&rvl); if (rvl > 0) { dt = rvl; } } if (dparm) { sprintf(otarget,"lp1=%d,lp2=%d,delta=%d",lp1,lp2,dt); vsa_position(dev_handle,(short)0,(short)0,&x_out,&y_out); v_bar(dev_handle,lobox); v_atext(dev_handle,otarget,&x_out,&y_out); }