Translation means repositioning of an object from place to another in a straight path by adding a translation factor or distance *t _{x} *and

*t*. Together (t

_{y}_{x},t

_{y}) are named as

**translation vector**.

Suppose, there is a point on the coordinate (x,y), in order to move this point to a new position, we have to add something which can be considered as translation vector (t_{x},t_{y}). The resultant point we would get is (x_{1},y_{1}).

A = (x,y) , Point that need to be translated

V= (t_{x},t_{y}) , This tells how much we have to move that point X

B = (x_{1},y_{1}) , The new point after translation

**x1 = x+ t _{x}**

**y1 =y+y _{1}**

## C Program to show the working of translation

**Program:**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
/* translation */ #include<conio.h> #include<graphics.h> #include<stdio.h> void main() { int gd=DETECT,gm; int x_initial,y_initial,x_final,y_final, x_vector,y_vector; clrscr(); initgraph(&gd,&gm,"C:\\TURBOC3\\BGI"); printf("\n Please enter an initial coordinate of the line = "); scanf("%d %d", &x_initial,&y_initial); printf("\n Now, \n enter final coordinate of the line = "); scanf("%d %d",&x_final,&y_final); printf("\n\t\t********** line before & after translation ***********"); printf("\nFirst enter the translation vector = "); scanf("%d %d",&x_vector,&y_vector); line(x_initial,y_initial,x_final,y_final); setcolor(RED); x_initial= x_initial+x_vector; y_initial= y_initial+y_vector; x_final= x_final+x_vector; y_final= y_final+y_vector; line(x_initial,y_initial,x_final,y_final); getch(); closegraph(); } |

**Output:**

You must be logged in to take the quiz.