Dda Line Drawing Algorithm
Dda Line Drawing Algorithm
#include<stdio.h>#include<conio.h>#include<graphics.h>
//
Translation vector from the user and translate the triangle accordingly//
#include<stdio.h>#include<conio.h>#include<graphics.h>
///scalling vector from the user and translate the triangle accordingly.///
#include<stdio.h>#include<conio.h>#include<graphics.h>
void main(),,{,,int gdriver=DETECT;
int gmode,i,j,k,a[3][3],b[3][3],c[3][3],sx,sy;
initgraph(&gdriver,&gmode," "); printf("\nEnter the
scalling vector sx: "); scanf("%d",&sx); printf("\nEnter the
scalling vector sy: "); scanf("%d",&sy); for(i=0;i<=2;i++)
{for(j=0;j<=2;j++){if(i==j),,a[i][j]=1; else,,a[i][j]=0;
a[0][0]=sx; a[1][1]=sy; }},,printf("\nEnter the coordinates
points of triangle:\n"); for(i=0;i<=2;i++),,{,,
for(j=0;j<=2;j++),,{,, if(i==2),,b[i][j]=1; else,,
scanf("%d",&b[i][j]); }},,for(i=0;i<=2;i++),,{,,
for(j=0;j<=2;j++),,{,,c[i][j]=0; for(k=0;k<=2;k++),,{
c[i][j]+=(a[i][k]*b[k][j]); }}},,,printf("\nScalling
Coordinates are:\n"); for(i=0;i<=2;i++),,{,,
for(j=0;j<=2;j++),,{,, printf("%d",c[i][j]); printf("\t");}
printf("\n"); },,line(c[0][0],c[1][0],c[0][1],c[1][1]);
line(c[0][2],c[1][2],c[0][0],c[1][0]);line(c[0][1],c[1][1],c[0][
2],c[1][2]);getch();closegraph();}
#include<stdio.h>#include<stdlib.h>#include<graphics.h>
#include<stdio.h>#include<conio.h>#include<graphics.h>