I have written a simple code to rotate a line. Following is the source code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#include<graphics.h>
void main(){
int gd=DETECT, gm;
int x1, y1, x2, y2, t, deg, b1, b2;
initgraph(&gd,&gm,"c:\\tc\\bgi");
printf("Enter coordinates of line: ");
scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
printf("Enter angle of rotation: ");
scanf("%d",°);
line(x1, y1, x2, y2);
getch();
t = (22*deg)/(180*7);
b1 = cos(t)*x1 - sin(t)*y1;
b2 = cos(t)*x1 + sin(t)*y1;
line(x1,y1,b1,b2);
getch();
closegraph();
}
The issue is that it generates a somewhat static output and does not rotate the line according to the input given. The rotated line is almost similar for any value deg variable.