Advertisement
Guest User

ГОВНО ЕБАНОЕ

a guest
May 4th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. //Каплун Сергей 1110 Группа 4 задача(графика) вариант №20
  2. #include <iostream>
  3. #include <windows.h>
  4. #include "resource.h"
  5. #include <stdlib.h>
  6. # include <math.h>
  7.  
  8. #define F 50
  9. #define g 9.8
  10.  
  11. using namespace std;
  12.  
  13. int x[F], y[F], t[F];
  14. double x11[F], y11[F], t11[F];
  15. double R, v, a0;
  16. double min1, max2 =2*R, min2, max1 = 0;
  17.  
  18.  
  19. int WINAPI DlgProc(HWND hDlg, WORD wMsg, WORD wParam, DWORD) {
  20. PAINTSTRUCT ps;
  21. if (wMsg == WM_CLOSE || wMsg == WM_COMMAND && wParam == IDOK) {
  22. EndDialog(hDlg, 0);
  23. }
  24. else
  25. if (wMsg == WM_INITDIALOG) {
  26. RECT rc;
  27. GetClientRect(hDlg, &rc);
  28. int dx = rc.right - rc.left;
  29. int dy = rc.bottom - rc.top;
  30. min2 = -R;
  31. min1 = 0;
  32. for (int i = 0; i < F; i++) {
  33.  
  34. if (x11[i] < min2) min2 = x11[i];
  35. if (x11[i] > max2) max2 = x11[i];
  36. if (y11[i] < min2) min2 = y11[i];
  37. if (y11[i] > max2) max2 = y11[i];
  38. if (t11[i] < min1) min1 = t11[i];
  39. if (t11[i] > max1) max1 = t11[i];
  40. }
  41. for (int i = 0; i < F; i++) {
  42. x[i] = (int)((x11[i] - min2)*dy / (max2 - min2));
  43. y[i] = (int)((y11[i] - min2)*dy / (max2 - min2));
  44. t[i] = (int)((t11[i] - min1)*dx / (max1 - min1));
  45. }
  46. }
  47. else
  48. if (wMsg == WM_PAINT) {
  49. BeginPaint(hDlg, &ps);
  50. HPEN hPenx = (HPEN)CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
  51. HPEN hPeny = (HPEN)CreatePen(PS_SOLID, 1, RGB(0, 255, 0));
  52. HPEN hOldPenx = (HPEN)SelectObject(ps.hdc, hPenx);
  53.  
  54. POINT ptOld;
  55. for (int i = 0; i < F - 1; i++) {
  56. MoveToEx(ps.hdc, t[i], x[i], &ptOld);
  57. LineTo(ps.hdc, t[i + 1], x[i + 1]);
  58. }
  59. HPEN hOldPeny = (HPEN)SelectObject(ps.hdc, hPeny);
  60. for (int i = 0; i < F - 1; i++) {
  61. MoveToEx(ps.hdc, t[i], y[i], &ptOld);
  62. LineTo(ps.hdc, t[i + 1], y[i + 1]);
  63. }
  64. SelectObject(ps.hdc, hOldPenx);
  65. DeleteObject(hPenx);
  66. SelectObject(ps.hdc, hOldPeny);
  67. DeleteObject(hPeny);
  68. EndPaint(hDlg, &ps);
  69. }
  70. return 0;
  71. }
  72.  
  73.  
  74.  
  75.  
  76. void main() {
  77. double a[F];
  78. double J,w,m,R,E,dt,v;
  79. cout << "vvedite nachalnii ugol,massu,radius,vremya" << endl << flush;
  80. cin >> a[0]>>m>>R>>v;
  81. dt = v / F;
  82. J = m*R*R;
  83. E = -m*g*R*sin(a[0]) / J;
  84. w = 0;
  85. t11[0] = 0;
  86. x11[0] = R*sin(a[0]);
  87. y11[0] = R - R*cos(a[0]);
  88. for (int i = 1; i < F; i++) {
  89. a[i] = a[i - 1] + w*dt + E*dt*dt / 2;
  90. w = w + E*dt;
  91. if (a[i] > 0) E = -1 * m*g*R*sin(a[i]) / J;
  92. if (a[i] == 0) E = 0;
  93. else E = m*g*R*sin(a[i]) / J;
  94. x11[i] = R*sin(a[i]);
  95. y11[i] = R - R*cos(a[i]);
  96. t11[i] = i*dt;
  97. }
  98.  
  99. DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)DlgProc);
  100. system("pause");
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement