Search & Find out

Thursday, December 3, 2009

Rotation of circle



#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "math.h"
void main ()
{
    int gd,gm,maxx,maxy;
    float x,y,x1,y1,r,theta;
    clrscr ();
    printf ("Enter the coordinates: ");
    scanf ("%f%f",&x,&y);
    printf ("Enter the radius: ");
    scanf ("%f",&r);
    printf ("Enter angle: ");
    scanf ("%f",&theta);
    theta = theta * 3.14/180;
    detectgraph (&gd,&gm);
    initgraph (&gd,&gm,"c:\\TC\\BGI");
    maxx = getmaxx ();
    maxy = getmaxy ();
    line (0,maxy/2,maxx,maxy/2);
    line (maxx/2,0,maxx/2,maxy);
    circle (x+maxx/2,y+maxy/2,r);
    x1 = x * cos(theta) - y * sin(theta);
    y1 = x * sin(theta) + y * cos(theta);
    setcolor (14);
    circle (x1+maxx/2,y1+maxy/2,r);
getch ();
closegraph ();
}



Download the executable (.exe)  file for this program..
download

0 comments:

Post a Comment

 

My Blog List

Term of Use