Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<graphics.h>
- #include<math.h>
- #include<conio.h>
- #define MAXPTS 15
- #define PI 3.14159 /* Define a value for PI */
- struct PTS { /* used to get x and y co-ordinates */
- int x, y;
- };
- int main()
- {
- struct viewporttype vp;
- struct PTS points[MAXPTS];
- int i, j, h, w, xcenter, ycenter,gd=DETECT,gm;
- int radius, angle, step;
- double rads,AspectRatio;
- int xasp, yasp; /* Used to read the aspect ratio*/
- initgraph(&gd,&gm,"c:\\tc\\bgi");
- getaspectratio(&xasp,&yasp);
- AspectRatio = (double)xasp / (double)yasp; /* Get correction factor */
- getviewsettings( &vp );
- h = vp.bottom - vp.top;
- w = vp.right - vp.left;
- xcenter = w / 2; /* Determine the center of circle */
- ycenter = h / 2;
- radius = (h - 30) / (AspectRatio * 2);
- step = 360 / MAXPTS; /* Determine # of increments */
- angle = 0; /* Begin at zero degrees */
- for( i=0 ; i<MAXPTS ; ++i )
- { /* Determine circle intercepts */
- rads = (double)angle * PI / 180.0; /* Convert angle to radians */
- points[i].x = xcenter + (int)( cos(rads) * radius );
- points[i].y = ycenter - (int)( sin(rads) * radius * AspectRatio );
- angle += step; /* Move to next increment */
- }
- circle( xcenter, ycenter, radius ); /* Draw bounding circle */
- for( i=0 ; i<MAXPTS ; ++i )
- { /* Draw the cords to the circle */
- for( j=i ; j<MAXPTS ; ++j )
- { /* For each remaining intersect */
- moveto(points[i].x, points[i].y); /* Move to beginning of cord */
- lineto(points[j].x, points[j].y); /* Draw the cord */
- }
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement