-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtranslation_in_2d.cpp
40 lines (38 loc) · 1.02 KB
/
translation_in_2d.cpp
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
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <math.h>
void RectAngle(int x, int y, int Height, int Width)
{
line(x, y, x + Width, y);
line(x, y, x, y + Height);
line(x + Width, y, x + Width, y + Height);
line(x, y + Height, x + Width, y + Height);
}
void Translate(int x, int y, int Height, int Width)
{
int Newx, Newy, a, b;
printf("Enter the Translation coordinates: ");
scanf("%d%d", &Newx, &Newy);
cleardevice();
a = x + Newx;
b = y + Newy;
RectAngle(a, b, Height, Width);
}
int main()
{
int gd = DETECT, gm;
int x, y, Height, Width;
initgraph(&gd, &gm, (char *)" ");
printf("Enter the First point for the Rectangle: ");
scanf("%d%d", &x, &y);
printf("Enter the Height&Width for the Rectangle: ");
scanf("%d%d", &Height, &Width);
RectAngle(x, y, Height, Width);
getch();
cleardevice();
Translate(x, y, Height, Width);
RectAngle(x, y, Height, Width);
getch();
return 0;
}