Program in C++ to illustrate the implementation of translation transformation of a 3D(3Dimensional) object .

This program needs the library file 3dframe.cpp,so download it first and put it in the BIN directory of Turbo C++ installation path .


Read about : Functionalities provided by this 3dframe.cpp library file and download it


Use the Contact form to post any question or comment regarding these programs.

The following code is tested on Turbo C++ Version 3.0


Click here to see the output of the program


	  
/*
*********************************************************
Author:Satyabrata Jena
Program Created on Date:March-2007
*********************************************************

PROGRAM IN C++ TO ILLUSTRATE THE 
TRANSLATION TRANSFORMATION OF A 3-DIMENSIONAL OBJECT

*/

#include"3DFRAME.CPP"
#include<iostream.h>
void translate_polyhedron(int ,int ,int ,int,int ,int,int,int ,int );

void main()
{
    int gd=DETECT,gm;
    initgraph(&gd,&gm,"c:\\tc\\bgi");
    cout<<"\nEnter Your 3D-Frame Length:\n";
    cout<<"\nANY VALUE  BETWEEN 1000 - 30000:";
    cin>>frame_length;
    int x_start=0,y_start=0,z_start=0,l_x,b_y,h_z;
    cout<<"\nFor this frame:";
    cout<<"\nMaximum range of Length  = 0  TO \t";
    cout<<frame_length;
    cout<<"\nMaximum range of Breadth = 0  TO  \t";
    cout<<frame_length;
    cout<<"\nMaximum range of Height  = 0  TO  \t";
    cout<<frame_length;
    cout<<"\nEnter the Start point of the polyhedron\n";
    cin>>x_start>>y_start>>z_start;
    cout<<"\nEnter length,breadth,height of polyhedron:\n";
    cin>>l_x;
    cin>>b_y;
    cin>>h_z;
    getch();
    cleardevice();
    DRAW3DFRAME();
    //CREATE THE POLYHEDRON
    polyhedron(x_start,y_start,z_start,l_x,b_y,h_z);
    getch();
    cleardevice();
    int tx,ty,tz;
    cout<<"\nEnter the coordinates of translation vector:tx,ty,tz\n";
    cin>>tx;
    cin>>ty;
    cin>>tz;
    DRAW3DFRAME();
    outtextxy(25,40,"Before translation");
    polyhedron(x_start,y_start,z_start,l_x,b_y,h_z);
    getch();
    DRAW3DFRAME();
    outtextxy(25,40,"After translation");
    translate_polyhedron(x_start,y_start,z_start,l_x,b_y,h_z,tx,ty,tz);
    getch();
    closegraph();

}

void translate_polyhedron
(int x1,int y1,int z1,int l_x,int b_y,
int h_z,int tx,int ty,int tz)
{
      int X1,Y1,Z1;
       //translate  coodinates (x,y,z) of the polyhedron by
       // translation factor tx ,ty,tz
      translate_point(x1,y1,z1,tx,ty,tz);
      X1=P1[0][0];
      Y1=P1[0][1];
      Z1=P1[0][2];
      polyhedron(X1,Y1,Z1,l_x,b_y,h_z);

}


  
	  

Download source code of 3D object translation transformation program