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:-