3D TRANSLATION AND SCALING

 
3D TRANSLATION AND SCALING
          AIM:

                        To write a program implementing  3D transformation as Translation and Scaling.

         ALGORITHM:

·         Start a program

·         Declare the variables and use graphics functions

·         Create the image to implements a 3D transformation

·         First image to translation P=T.P and change a image 3D scaling P=S.P

·         Print the output of 3D image translation and scaling

·         Stop the program


CODINGS:

#include<stdio.h>
#include<conio.h>     
#include<stdlib.h>
#include<graphics.h>
void main()
{
int x,y,z;
int x1=100,y1=150,x2=200,y2=250;
int a1=10,b1=20,a2=30,b2=40;
int gdriver=DETECT,gmode,errorcode;
initgraph(&gdriver,&gmode,"");
bar3d(x1,y1,x2,y2,(x2-x1)/4,1);
printf("Enter the translation value x&y:");
scanf("%d%d",&x,&y);
x1=x1+x;
x2=x2+x;
y1=y1+y;
y2=y2+y;
bar3d(x1,y1,x2,y2,(x2-x1)/4,1);
getch();
cleardevice();
bar3d(a1,b1,a2,b2,(a2-a1)/4,1);
printf("\nEnter the scaling factor a:");
scanf("%d",&z);
a1=a1*z;
a2=a2*z;
b1=b1*z;
b2=b2*z;
bar3d(a1,b1,a2,b2,(a2-a1)/4,1);
getch();
}


OUTPUT:

Enter the translation values x & y:
100
            200

Enter the scaling factor a:5






RESULT:

            Thus, the program has been successfully executed & output is verified.

Comments