FOR TRANSLATION


#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void dda(int x1,int x2,int y1,int y2)
{
float dx,dy,steps,x,y;
float xinc,yinc;
int k;
dx=abs(x2-x1);
dy=abs(y2-y1);
if(dx>dy)
steps=dx;
xinc=dx/steps;
yinc=dy/steps;
x=x1;
y=y1;
putpixel(x,y,10);
for(k=0;k<=steps;k++)
{        x+=xinc;
y+=yinc;
putpixel(x,y,10);
}
getch();
}
void main()
{
int tx,ty,x1,x2,y1,y2;
float xinc,yinc;
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
printf("enter the starting coordinate");
scanf("%d,%d",&x1,&y1);
printf("enter the end coordinate");
scanf("%d,%d",&x2,&y2);
dda(x1,y1,x2,y2);
printf("enter the xaxis translation" );
scanf("%d",&ty);
x1+=tx;
x2+=tx;
y1+=ty;
y2+=ty ;
printf("translation line");
dda(x1,x2,y1,y2);
closegraph();
}

Comments

Popular posts from this blog

REFLECTION OF A TRIANGLE (COMPUTER GRAPHICS)