TRIANGLE ROTATION PROGRAM
Similar Programs
- Flood Fill program in C
- Triangle Rotation Program
- Text animation program in C
- C program for fixed point scaling and rotation
- C Program for shearing of triangle, line and rectangle
- C program to plot different types of lines
- Scaling program in C
- Font animation program in C
- Midpoint ellipse drawing program in C
- Circle Midpoint program in C
- Translation program in C
- Bresenhem Circle drawing program in C
- String Generation program in C
- Bresenhem Line drawing program in C
- Plotting a pixel in C
- DDA line drawing program in C
- Boundary fill program in C
- Character Generation program in C
- Triangle Rotation program in C
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<process.h> #include<math.h> void triangle(int x1,int y1,int x2,int y2,int x3,int y3); void Rotate(int x1,int y1,int x2,int y2,int x3,int y3); void main() { int gd=DETECT,gm; int x1,y1,x2,y2,x3,y3; initgraph(&gd,&gm,"c:\\tc\\bgi"); printf("Enter the 1st point for the triangle:"); scanf("%d%d",&x1,&y1); printf("Enter the 2nd point for the triangle:"); scanf("%d%d",&x2,&y2); printf("Enter the 3rd point for the triangle:"); scanf("%d%d",&x3,&y3); triangle(x1,y1,x2,y2,x3,y3); getch(); cleardevice(); Rotate(x1,y1,x2,y2,x3,y3); setcolor(1); triangle(x1,y1,x2,y2,x3,y3); getch(); } void triangle(int x1,int y1,int x2,int y2,int x3,int y3) { line(x1,y1,x2,y2); line(x2,y2,x3,y3); line(x3,y3,x1,y1); } void Rotate(int x1,int y1,int x2,int y2,int x3,int y3) { int x,y,a1,b1,a2,b2,a3,b3,p=x2,q=y2; float Angle; printf("Enter the angle for rotation:"); scanf("%f",&Angle); cleardevice(); Angle=(Angle*3.14)/180; a1=p+(x1-p)*cos(Angle)-(y1-q)*sin(Angle); b1=q+(x1-p)*sin(Angle)+(y1-q)*cos(Angle); a2=p+(x2-p)*cos(Angle)-(y2-q)*sin(Angle); b2=q+(x2-p)*sin(Angle)+(y2-q)*cos(Angle); a3=p+(x3-p)*cos(Angle)-(y3-q)*sin(Angle); b3=q+(x3-p)*sin(Angle)+(y3-q)*cos(Angle); printf("Rotate"); triangle(a1,b1,a2,b2,a3,b3); }
This comment has been removed by the author.
ReplyDeleteIt is the destination coordinate point for x-axis.
DeleteTo keep us motivated, Please like and subscribe our YouTube channel Appychip
https://goo.gl/BseuJN