Академический Документы
Профессиональный Документы
Культура Документы
ASSIEMENT-3
NAME:-Abdela Aman
ROLLNO:-16071059
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<iostream>
#include<math.h>
void direct(int,int,int,int);
void polar_domain(int,int,int,int);
void polar_incremental_domain(int,int,int,int);
void Mid_point(int,int,int,int);
void drawEllipse(int,int,int,int);
int main()
int h,k,a,b;
char c;
int ch;
initgraph(&gdriver,&gmode,"C:\Users\pc\Desktop\nmok\";
do
1
Punjabi university ,computer science department
cin>>ch;
switch(ch)
case 1:
cin>>h>>k;
cin>>a>>b;
direct(h,k,a,b);
break;
case 2:
cin>>h>>k;
cin>>a>>b;
polar_domain(h,k,a,b);
break;
case 3:
cin>>h>>k;
2
Punjabi university ,computer science department
cin>>a>>b;
polar_incremental_domain(h,k,a,b);
break;
case 4:
cin>>h>>k;
cin>>a>>b;
Mid_point(h,k,a,b);
break;
default:
cout<<"wrong choice"<<endl;
break;
cin>>c;
}while(c=='Y'|| c=='y');
getch();
closegraph();
double x,y,xend;
x=0;
3
Punjabi university ,computer science department
xend=a;
while(x<=xend)
y=b*sqrt(1-(x*x)/(a*a));
//putpixel(x,y,RED);
putpixel(x+h,y+k,RED);
putpixel(h-x,y+k,RED);
putpixel(h-x,k-y,RED);
putpixel(h+x,k-y,RED);
x=x+1;
ellipse(h,k,0,360,a,b);
getch();
closegraph();
double dtheta,theta,x,y;
if(a>b)
dtheta=(1.0/(double)a);
else
dtheta=(1.0/(double)b);
4
Punjabi university ,computer science department
theta=0;
while(theta<=3.14)
x=(int)(a*cos(theta)+0.5);
y=(int)(b*sin(theta)+0.5);
putpixel(h+x,k+y,RED);
putpixel(h+x,k-y,RED);
putpixel(h-x,k-y,RED);
putpixel(h-x,k+y,RED);
theta=theta+dtheta;
/* clean up */
getch();
closegraph();
double dtheta,x,y,c,s,Tab,Tba,xtemp;
if(a>b)
dtheta=1.0/(double)a;
else
dtheta=1.0/(double)b;
5
Punjabi university ,computer science department
x=a;
y=0;
c=cos(dtheta);
s=sin(dtheta);
//theta=0;
Tab=(double)a/(double)b;
Tba=(double)b/(double)a;
while (y<=b)
xtemp=x;
x=(xtemp*c)-(Tab*y*s);
y=(y*c)+(Tba*xtemp*s);
putpixel(h+x,k+y,RED);
putpixel(h+k,k-y,RED);
putpixel(h-x,k-y,RED);
putpixel(h-x,k+y,RED);
ellipse(h,k,0,360,a,b);
getch();
closegraph();
////////////////////////////////////////////////////////////
6
Punjabi university ,computer science department
xradius = a, yradius = b;
midx = h;
midy = k;
twoxrad2 = 2 * xrad2;
twoyrad2 = 2 * yrad2;
x = dpx = 0;
y = yradius;
dpy = twoxrad2 * y;
x = x + 1;
if (dp < 0) {
dp = dp + yrad2 + dpx;
} else {
y = y - 1;
7
Punjabi university ,computer science department
delay(100);
delay(500);
while (y > 0) {
y = y - 1;
if (dp > 0) {
dp = dp + xrad2 - dpy;
} else {
x = x + 1;
8
Punjabi university ,computer science department
delay(100);
ellipse(midx,midy,0,360,xradius,yradius);
getch();
closegraph();
//return 0;