Bolonka

Untitled

Jul 2nd, 2023
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. #define SPACE_SIZE 31
  6. #define INDENT 10
  7.  
  8. struct space_point_str {
  9. int x;
  10. int y;
  11.  
  12. char type;
  13. };
  14.  
  15. struct square_point_srt {
  16. int x;
  17. int y;
  18.  
  19. float fl_x;
  20. float fl_y;
  21.  
  22. };
  23.  
  24. int main()
  25. {
  26.  
  27. int add = (SPACE_SIZE-1)/2;
  28.  
  29. int space_area = SPACE_SIZE*SPACE_SIZE;
  30. int square_size = (SPACE_SIZE - 2*INDENT);
  31. int square_area = ( (SPACE_SIZE - 2*INDENT)*(SPACE_SIZE - 2*INDENT) );
  32.  
  33. float angle = 0;
  34.  
  35. // Инициализация точек пространства
  36. struct space_point_str space_point[space_area];
  37. for(int i=0;i<space_area;i++) {
  38. space_point[i].x = (i%SPACE_SIZE)-add;
  39. space_point[i].y = (i/SPACE_SIZE)-add;
  40. space_point[i].type = '0';
  41. }
  42.  
  43. //Инициализация точек квадрата
  44. struct square_point_srt square_point[square_area];
  45. for(int i=0;i<square_area;i++) {
  46. square_point[i].x = (i%square_size)-add+INDENT;
  47. square_point[i].y = (i/square_size)-add+INDENT;
  48.  
  49. square_point[i].fl_x = square_point[i].x;
  50. square_point[i].fl_x = square_point[i].y;
  51.  
  52. }
  53.  
  54.  
  55. while (1) {
  56.  
  57. angle += 0.01;
  58.  
  59. for(int i=0;i<space_area;i++) {
  60. for(int ii=0;ii<square_area;ii++) {
  61. if( (space_point[i].x == square_point[ii].x) && (space_point[i].y == square_point[ii].y) ) {
  62. space_point[i].type = '1';
  63. break;
  64. }
  65. else {
  66. space_point[i].type = ' ';
  67. }
  68. }
  69.  
  70. if ( (i%SPACE_SIZE) == 0) {
  71. printf("\n");
  72. }
  73. printf("%c ",space_point[i].type);
  74. }
  75.  
  76. usleep(4000);
  77. system("cls");
  78. for(int i=0;i<square_area;i++) {
  79. square_point[i].fl_x = ( square_point[i].fl_x*cos(angle) ) - ( square_point[i].fl_y*sin(angle) );
  80. square_point[i].fl_y = ( square_point[i].fl_y*cos(angle) ) + ( square_point[i].fl_x*sin(angle) );
  81.  
  82. square_point[i].x = (int)round(square_point[i].fl_x);
  83. square_point[i].y = (int)round(square_point[i].fl_y);
  84. }
  85. }
  86.  
  87.  
  88. } // конец мейн функции
  89.  
Advertisement
Add Comment
Please, Sign In to add comment