ashutosh_cg
ashutosh_cg
PRACTICAL FILE
ON
SUBMITTED TO
JIWAJI UNIVERSITY, GWALIOR (M.P.)
Master Of Science
In
Computer Science
ADADEMIC YEAR 2021-22
Based on
Computer
Graphics
1. Write a program for mid point circle
int main()
{
cout<<"This program was made by Ashutosh Rathore\n";
int x = 0,y = 0,a,b,r,k = 0,p;
cout<<"enter the value of a,b,r\n";
cin>>a>>b>>r;
x+=a;
y+=b;
y =r;
p = 1-r;
cout<<"\n";
cout<<"k"<<"\t"<<"pk"<<"\t"<<"(x,y)"<<"\n";
for(int i=0;i<30;i++)
cout<<"-";
cout<<"\n";
while ( x < y)
{
cout<<k<<"\t";
cout<<p<<"\t";
x++;
if(p<0)
{
p = p+2*x+1;
}
else
{
y--;
p = p + 2*x - 2*y + 1;
}
cout<<"("<<x<<","<<y<<")"<<"\n";
k++;
}
Output:
2. Write a program for bresenham’s line drawing algorithm
Output:
3.
int main()
{
printf("This program was made by Ashutosh Rathore");
int a, b, ya, yb, dx, dy, steps;
float xinc, yinc, x, y;
Output: