How to Solve this Practical Problems

Posted by Jayakumars under ASP.NET AJAX on 8/28/2014 | Points: 10 | Views : 1349 | Status : [Member] [MVP] | Replies : 1
Hi
I need this problem solutions any one Solve this

1.Line Using Dda Line Drawing Algorithm
2.Line Using Bresenhams Line Drawing Algorithm
3.Circle Using Bresenhams Circle Generating Algorithm
4.Ellipse Using Bresenhams Ellipse Generating Algorithm
5.Circuit Using Dda Line Drawing Algorithm

Mark as Answer if its helpful to you

Kumaraspcode2009@gmail.com

Responses

Posted by: Jayakumars on: 8/28/2014 [Member] [MVP] Bronze | Points: 25
 0 #include#include#include#includevoid main(){ float x,y,dx,dy;int x1,y1,x2,y2,i,length;int gdriver=DETECT,gmode;initgraph(&gdriver,&gmode,”C:\TC\BGI”);cout<<”Enter co-ordinates of point 1:”;cin>>x1>>y1;cout<<” Enter co-ordinates of point 2:”;cin>>x2>>y2;dx=abs(x2-x1);dy=abs(y2-y1);if(dx>=dy)length=dx;else length=dy;dx=dx/length;dy=dy/length;x=x1;y=y1;i=1;while(i#include#include#includevoid main(){ float x,y,dx,dy;int x1,y1,x2,y2,i,e,x,y,dx,dy;int gdriver=DETECT,gmode;initgraph(&gdriver,&gmode,”C:\TC\BGI”);cout<<”Enter the co-ordinates of point 1:”;cin>>x1>>y1;cout<<” Enter the co-ordinates of point 2:”;cin>>x2>>y2;dx=abs(x2-x1);dy=abs(y2-y1);if(dx>=dy)length=dx;else length=dy;dx=dx/length;dy=dy/length;x=x1;y=y1;e=2*dy-dx;i=1;do{ putpixel(x,y,WHITE);while(e>=0){y++;e=e-2*dx;putpixel(x,y,WHITE);}x++;e=e+2*dy;i++;}while(i<=dx);getch();closegraph();}#include#include#includeint r,x,y;float a,b,d;void bresan();void pixel(float a,float b);void main(){int gm,gr;clrscr();detectgraph(&gm,&gr);initgraph(&gm,&gr,"d:\\tc\\BGI");cout<<"Enter the center point:”;cin>>x>>y;cout<<"Enter the radius :”;cin>>r;bresan();getch();}void bresan(){a=0;b=r;d=3-(2*r);while(a<=b){a++;if(d>=0){b--;d=d+10+4*(a-b);}elsed=d+(4*a)+6;pixel(a,b);}}void pixel(float a,float b){putpixel(x+a,y+b,10);putpixel(x-a,y-b,10);putpixel(x+a,y-b,10);putpixel(x-a,y+b,10);putpixel(x+b,y+a,10);putpixel(x-b,y-a,10);putpixel(x+b,y-a,10);putpixel(x-b,y+a,10);}#include#include#include#includevoid disp();float x,y;int xc,yc;void main(){int gd=DETECT,gm;int a,b;float p1,p2;clrscr();initgraph(&gd,&gm,"");cout<<”Enter the co-corinates”;cin>>xc>>yc>>a>>b;x=0;y=b;disp();p1=(b*b)-(a*a*b)+(a*a)/4;while((2.0*b*b*x)<=(2.0*a*a*y)){x++;if(p1<=0)p1=p1+(2.0*b*b*x)+(b*b);else{y--;p1=p1+(2.0*b*b*x)+(b*b)-(2.0*a*a*y);}disp();x=-x;disp();x=-x;}x=a;y=0;disp();p2=(a*a)+2.0*(b*b*a)+(b*b)/4;while((2.0*b*b*x)>(2.0*a*a*y)){y++;if(p2>0)p2=p2+(a*a)-(2.0*a*a*y);else{x--;p2=p2+(2.0*b*b*x)-(2.0*a*a*y)+(a*a);}disp();y=-y;disp();y=-y;}getch();closegraph();}void disp(){putpixel(xc+x,yc+y,10);putpixel(xc-x,yc+y,10);putpixel(xc+x,yc-y,10);putpixel(xc+x,yc-y,10);}#include#include#include#include#include#include#includeclass lines { private: int length,x1,y1,x2,y2,x,y,dx,dy,wx,wy,w,width; public: lines(); //Constructor void showline(); int sign(int); };int lines::sign(int xx) { if(xx<0) return -1; if(xx==0) return 0; if(xx>0) return 1; return 0; }lines::lines() { x=0;y=0; cout<<"Enter The Co-Ordinates (x1,y1) ":="; cin>>x1>>y1; cout<<"Enter The Co-Ordinates (x2,y2) ":="; cin>>x2>>y2; cout<<"Enter The Width Of The Line ":="; cin>>width; }void lines::showline() { char *s,*s1; if(abs(x2-x1)>=abs(y2-y1)) length=abs(x2-x1); else length=abs(y2-y1); w=width; wx=((w-1)/2)*(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))/abs(y2-y1)); wy=((w-1)/2)*(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))/abs(x2-x1)); dx=(x2-x1)/length; dy=(y2-y1)/length; if(dy>dx) wy=wx; x=x1+0.5*sign(dx); y=y1+0.5*sign(dy); int i=1; setcolor(0); while(i<=length) { for(int j=0;j=6;i++,j--) { xx+=10; outtextxy(xx,10,mess[i]); xxx-=10; outtextxy(xxx,10,mess[j]); delay(100); } for(i=130;i<=510;i+=10) for(j=50;j<=430;j+=10) putpixel(i,j,15); for(i=130;i<=510;i+=10) { if(i==320) continue; outtextxy(i,237,"+"); } for(i=50;i<=430;i+=10) { if(i==240) continue; outtextxy(317,i,"-"); } outtextxy(310,230,"O"); outtextxy(530,240,"X"); outtextxy(320,450,"-Y"); outtextxy(100,240,"-X"); outtextxy(320,30,"Y"); a.showline(); closegraph(); }Mark as Answer if its helpful to you Kumaraspcode2009@gmail.comJayakumars, if this helps please login to Mark As Answer. | Alert Moderator
Latest Posts