C++ PROGRAM TO IMPLEMENT THE CONCEPT OF TRANSLATION

C++ PROGRAM TO IMPLEMENT THE CONCEPT OF TRANSLATION

CODE:

#include<stdio.h>

#include<graphics.h>

#include<conio.h>

int main()

{

    int gd=DETECT,gm;

    int x,y,x1,y1,x2,y2,tx,ty;

    initgraph(&gd,&gm,"C:\\WINDOWS\\BGI");

    printf("\n Enter the first coordinates of the triangle: ");

    scanf("%d %d",&x,&y);

    printf("\n Enter the second coordinates of the traingle: ");

    scanf("%d %d",&x1,&y1);

    printf("\n Enter the third coordinates of the traingle: ");

    scanf("%d %d",&x2,&y2);

    printf("\n\t\t************TRIANGLE BEFORE AND AFTER TRANSLATION*************");

    line(x,y,x1,y1);

    line(x1,y1,x2,y2);

    line(x2,y2,x,y);

    outtextxy(x1,y1+5,"BEFORE TRANSLATION");

    printf("\n Now enter the translation vector: ");

    scanf("%d %d",&tx,&ty);

    setcolor(YELLOW);

    line(x+tx,y+ty,x1+tx,y1+ty);

    line(x1+tx,y1+ty,x2+tx,y2+ty);

    line(x2+tx,y2+ty,x+tx,y+ty);

    outtextxy(x1+tx,y1+ty+5,"AFTER TRANSLATION");

    getch();

    closegraph();

    return 0;

}


OUTPUT:


 Enter the first coordinates of the triangle: 50 50 100 150 150 50


 Enter the second coordinates of the traingle:

 Enter the third coordinates of the traingle:

                ************TRIANGLE BEFORE AND AFTER TRANSLATION*************

 Now enter the translation vector: 100 150

_________________________________________________________________________





Comments

Popular posts from this blog

C++ PROGRAM TO IMPLEMENT THE CONCEPT OF REFLEXION

C++ PROGRAM TO IMPLEMENT THE CONCEPT OF FIXED SCALING

C++ PROGRAM TO IMPLEMEMT THE CONCEPT OF FLOODFILL ALGORITHM