Advertisement
Guest User

Untitled

a guest
Apr 25th, 2014
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<conio.h>
  3. #include<graphics.h>
  4. #include<math.h>
  5.  
  6. void main()
  7. {
  8. clrscr();
  9. int gd=DETECT, gm;
  10. initgraph(&gd, &gm,"D:\TC\BGI");
  11. double x1, x2, y1, y2, x3, x4, x5, x6, x7, x8, x9, y3, y4, y5, y6, y7, y8, y9, tx,ty, d;
  12. x1=50;
  13. y1=50;
  14. x2=100;
  15. y2=50;
  16. d=45;
  17. tx=50;
  18. ty=50;
  19. double tempx, tempy;
  20. tempx = x2;
  21. tempy = y2;
  22. line(x1,y1,x2,y2);
  23. circle(50,50,50);
  24. for(int z=0;z<7;z++)
  25. {
  26. double p[3][3]={{cos(d),sin(d),0},{-sin(d),cos(d),0},{tx*(1-cos(d))+ty*sin(d),ty*(1-
  27.  
  28. cos(d))-tx*sin(d),1}};
  29. double m[3][3]={{x1,y1,1},{tempx,tempy,1},{0,0,1}};
  30. double M[3][3];
  31. for(int i=0; i<3 ;i++)
  32. {
  33. for(int j=0;j<3;j++)
  34. {
  35. M[i][j]=0;
  36. for(int k=0;k<3;k++)
  37. {
  38. M[i][j]=M[i][j]+m[i][k]*p[k][j];
  39. }
  40. }
  41. }
  42. line(M[2][0],M[2][1],M[0][0],M[0][1]);
  43. tempx = M[0][0];
  44. tempy = M[0][1];
  45. switch(z)
  46. {
  47. case 0 : x3=tempx;
  48. y3=tempy;
  49. break;
  50. case 1 : x4=tempx;
  51. y4=tempy;
  52. break;
  53. case 2 : x5=tempx;
  54. y5=tempy;
  55. break;
  56. case 3 : x6=tempx;
  57. y6=tempy;
  58. break;
  59. case 4 : x7=tempx;
  60. y7=tempy;
  61. break;
  62. case 5 : x8=tempx;
  63. y8=tempy;
  64. break;
  65. case 6 : x9=tempx;
  66. y9=tempy;
  67. break;
  68. }
  69. }
  70. cout<<"n";
  71. for(int i=0;i<7;i++)
  72. {
  73. switch(1)
  74. {
  75. case 0 : cout<<x3<<y3<<"n";
  76. break;
  77. case 1 : cout<<x4<<y4<<"n";
  78. break;
  79. case 2 : cout<<x5<<y5<<"n";
  80. break;
  81. case 3 : cout<<x6<<y6<<"n";
  82. break;
  83. case 4 : cout<<x7<<y7<<"n";
  84. break;
  85. case 5 : cout<<x8<<y8<<"n";
  86. break;
  87. case 6 : cout<<x9<<y9<<"n";
  88. break;
  89.  
  90. }
  91. getch();
  92. closegraph();
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement