Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.41 KB | None | 0 0
  1. //----------------------
  2. #include <windows.h>
  3. #include <tchar.h>
  4. #include <cmath>
  5. #include <math.h>
  6. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  7. TCHAR WinName[] = _T("MainFrame");
  8. //---------------------
  9. int APIENTRY WinMain(HINSTANCE This, HINSTANCE Prev, LPSTR cmd, int mode)
  10. {
  11.     HWND hWnd;
  12.     MSG msg;
  13.     WNDCLASS wc;
  14.     wc.hInstance = This;
  15.     wc.lpszClassName = WinName;
  16.     wc.lpfnWndProc = WndProc;
  17.     wc.style = CS_HREDRAW | CS_VREDRAW;
  18.     wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  19.     wc.hCursor = LoadCursor (NULL, IDC_ARROW);
  20.     wc.lpszMenuName = NULL;
  21.     wc.cbClsExtra = 0;
  22.     wc.cbWndExtra = 0;
  23.     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
  24.     if (!RegisterClass(&wc)) return 0;
  25.     hWnd = CreateWindow(WinName, _T("Каркас Windows-приложения"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP,
  26.     NULL,
  27.     This,
  28.     NULL);
  29.     ShowWindow(hWnd, mode);
  30.     while (GetMessage(&msg, NULL, 0, 0))
  31.     {
  32.         TranslateMessage(&msg);
  33.         DispatchMessage(&msg);
  34.  
  35.     }
  36.     return 0;
  37. }
  38.  
  39.  
  40.  
  41. LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  42. {
  43.     PAINTSTRUCT ps;
  44.     const int WIDTH = 400;
  45.     const int HEIGHT = 300;
  46.     float v11, v12, v13, v21, v22, v23, v31, v32, v33, v43;
  47.     float rho = 300.,thetta = 75., phi = 30., ScreenDist = 500.;
  48.     float A, B, C, D, An, Bn, Cn;
  49.     float xt[3], yt[3], zt[3];
  50.     float Al, Bl, Cl;
  51.     float alpha;
  52.     float th, ph, costh, cosph, sinth, sinph;
  53.     float factor = atan(1.0)/45.;
  54.     static HBRUSH hBrush;
  55.     class TFPoint {
  56.     public:
  57.         float X;
  58.         float Y;
  59.         float Z;
  60.     };
  61.  
  62.     TFPoint CubePoints[]= {
  63.         {-50, -50, -50}
  64.         {50, -50, -50}
  65.         {50, 50, -50}
  66.         {-50, 50, -50}
  67.         {-50, 50, 50}
  68.         {-50, -50, 50}
  69.         {50, -50, 50}
  70.         {50, 50, 50}
  71.     };
  72.     int Gran [6][4]= {
  73.         {0,3,4,5}
  74.         {0,5,6,1}
  75.         {2,7,4,3}
  76.         {7,6,5,4}
  77.         {0,1,2,3}
  78.         {2,1,6,7}
  79.     };
  80.  
  81.     void VidMatCoeff (float rho,float thetta, float phi);
  82.     {
  83.         th = thetta * factor;
  84.         ph = phi * factor;
  85.         costh = cos(th);
  86.         sinth = sin(th);
  87.         cosph = cos (ph);
  88.         sinph = sin (ph);
  89.         v11 = -sinth; v12 = -cosph * costh; v13 = -sinph * costh;
  90.         v21 = costh; v22 = -cosph * sinth; v23 = -sinph * sinth;
  91.         v31 = 0; v32 = sinph; v33 = -cosph;
  92.         v43 = rho;
  93.     }
  94.     POINT Perspective (float x, float y, float z) {
  95.         POINT point;
  96.         float xe, ye, ze;
  97.         VidMatCoeff (rho, thetta, phi);
  98.         xe = v11 * x + v21 * y;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement