Advertisement
zoro-10

7A. Perform 2D Rotation on a given object.

Apr 1st, 2024
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include<graphics.h>
  2. #include<iostream.h>
  3. #include<conio.h>
  4. #include<math.h>
  5. void main()
  6. {
  7. int x1,y1,x2,y2,xn,yn;
  8. double th;
  9. float t;
  10. int gd=DETECT,gm;
  11. initgraph(&gd,&gm,"C:\\TurboC3\\BGI");
  12. cout<<"Enter the first co-ordinate:";
  13. cin>>x1>>y1;
  14. cout<<"Enter second co-ordinate:";
  15. cin>>x2>>y2;
  16. line(x1,y1,x2,y2);
  17. cout<<"Enter the angle:";
  18. cin>>th;
  19. t=(22*th)/(180*7);
  20. xn=abs((x2*cos(t))-(y2*sin(t)));
  21. yn=abs((x2*sin(t))+(y2*cos(t)));
  22. line(x1,y1,xn,yn);
  23. getch();
  24. closegraph();
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement