0% found this document useful (0 votes)
19 views4 pages

Experiment Title:: Write A Program in C To Perform Two Dimensional Transformation (Rotation)

The document presents a C program for performing two-dimensional transformations, specifically rotation of a line. It includes the program code that prompts the user for line coordinates and a rotation angle, calculates the new coordinates using trigonometric functions, and displays the transformed line. The program utilizes graphics functions to render the output visually.

Uploaded by

aafu202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views4 pages

Experiment Title:: Write A Program in C To Perform Two Dimensional Transformation (Rotation)

The document presents a C program for performing two-dimensional transformations, specifically rotation of a line. It includes the program code that prompts the user for line coordinates and a rotation angle, calculates the new coordinates using trigonometric functions, and displays the transformed line. The program utilizes graphics functions to render the output visually.

Uploaded by

aafu202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

`

Name of Student Adityaraj Kashid


Roll No. 20203A0007
Class C03-A
Seat No 112815
Date 10/01/2022

Experiment Title:

Write a program in C to perform two dimensional transformation (Rotation)

Program Code:

#include<stdio.h>
#include<graphics.h>
#include<math.h>
int main()
{
int gd=0,gm,x1,y1,x2,y2;
double s,c, angle;
initgraph(&gd, &gm, "c:\\turboc3\\bgi");
setcolor(RED);
printf("Enter coordinates of line: ");
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
cleardevice();
line(x1,y1,x2,y2);
getch();
setbkcolor(BLACK);

1
`

printf("Enter rotation angle: ");


scanf("%lf", &angle);
c = cos(angle *3.14/180);
s = sin(angle *3.14/180);
x1 = floor(x1 * c + y1 * s);
y1 = floor(-x1 * s + y1 * c);
x2 = floor(x2 * c + y2 * s);
y2 = floor(-x2 * s + y2 * c);
cleardevice();
line(x1, y1 ,x2, y2);
getch();
closegraph();
return 0;
}

Output:

2
`

3
`

You might also like