0% found this document useful (0 votes)
127 views2 pages

Practical 11CGR

The document provides a C program for performing 3D rotation using graphics. It includes user input for rotation angle and new coordinates, and it calculates the new position of a 3D bar based on the input. The program utilizes trigonometric functions for rotation and scaling in a graphical environment.
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)
127 views2 pages

Practical 11CGR

The document provides a C program for performing 3D rotation using graphics. It includes user input for rotation angle and new coordinates, and it calculates the new position of a 3D bar based on the input. The program utilizes trigonometric functions for rotation and scaling in a graphical environment.
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

Practical-No:-11

-Write a C program for 3D Rotation.


Code:-
#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>

#define PI 3.14159265358979323846

void main() {
int gd = DETECT, gm;
int x, y, z, size = 50;
float angle;
int newX, newY;

initgraph(&gd, &gm, " "a);

bar3d(100, 100, 200, 200, 25, 1);

printf("\nEnter the rotation angle in degrees: ");


scanf("%f", &angle);

printf("Enter the New X & Y: ");


scanf("%d%d", &x, &y);

newX = x * cos(angle * PI / 180.0) - y * sin(angle * PI / 180.0);


newY = x * sin(angle * PI / 180.0) + y * cos(angle * PI / 180.0);
printf("Enter New Scaling Function: ");
scanf("%d", &z);

bar3d(100 + newX, 100 + newY, 200 + newX, 200 + newY, 25 * z, 1);

getch();
closegraph();
}

Output:-

You might also like