0% found this document useful (0 votes)
60 views3 pages

Objective-Program-: Write A Program To Perform Two-Dimensional Rotation On An Object

The program takes as input the endpoints of a line, an angle of rotation, and performs a 2D rotation of the line on the graph. It initializes graphics mode, displays the original line, calculates the new x and y coordinates of the endpoint after applying a rotation matrix, and draws the line again with the rotated endpoint.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views3 pages

Objective-Program-: Write A Program To Perform Two-Dimensional Rotation On An Object

The program takes as input the endpoints of a line, an angle of rotation, and performs a 2D rotation of the line on the graph. It initializes graphics mode, displays the original line, calculates the new x and y coordinates of the endpoint after applying a rotation matrix, and draws the line again with the rotated endpoint.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

OBJECTIVE-Write a program to perform Two-dimensional Rotation on an object.

PROGRAM-

#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
void main()
{
int graphdriver=DETECT,graphmode,errorcode;
int i;
int x2,y2,x1,y1,x,y,xn,yn;
double r11,r12,r21,r22,th;
clrscr();
printf("Enter the 2 line end points:");
printf("x1,y1,x2,y2");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
initgraph(&graphdriver,&graphmode,"c:\\tc\\bgi");
line(x1,y1,x2,y2);
printf("\n\n\n[ Enter the angle");
scanf("%lf",&th);
r11=cos((th*3.1428)/180);
r12=sin((th*3.1428)/180);
r21=(-sin((th*3.1428)/180));
r22=cos((th*3.1428)/180);
//printf("%lf  %lf  %lf  %lf",r11,r12,r21,r22);
xn=((x2*r11)-(y2*r12));
yn=((x2*r12)+(y2*r11));
line(x1,y1,xn,yn);
getch();
closegraph();
}

OUTPUT-

Before rotation
After rotation

You might also like