Kolyach

4.5 tan

Dec 3rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <Windows.h>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. const float PI = 3.14;
  9.  
  10. int main() {
  11.     HWND hWnd = GetConsoleWindow(); //дескриптор окна
  12.     HDC hDC = GetDC(hWnd); //дескриптор контекста устройства
  13.     HPEN Pen = CreatePen(PS_SOLID, 2, RGB(255, 255, 255));
  14.  
  15.     float scale = 30;
  16.  
  17.     POINT horizontalAxisCoordinates = { 25, 230 };
  18.     POINT horizontalLineCoordinates = { 500, horizontalAxisCoordinates.y };
  19.  
  20.     POINT verticalAxisCoordinates = { 250, 50 };
  21.     POINT verticalLineCoordinates = { verticalAxisCoordinates.x, 390 };
  22.  
  23.     SelectObject(hDC, Pen);
  24.  
  25.     MoveToEx(hDC, horizontalAxisCoordinates.x, horizontalAxisCoordinates.y, NULL);
  26.     LineTo(hDC, horizontalLineCoordinates.x, horizontalLineCoordinates.y);
  27.  
  28.     MoveToEx(hDC, verticalAxisCoordinates.x, verticalAxisCoordinates.y, NULL);
  29.     LineTo(hDC, verticalLineCoordinates.x, verticalLineCoordinates.y);
  30.  
  31.     for (float x = -PI/2; x <= PI/2; x += 0.01)
  32.     {
  33.         MoveToEx(hDC, (int)(scale * x +250), (int)(-scale * tan(x) + 230), NULL);
  34.         LineTo(hDC, (int)(scale * x + 250), (int)(-scale * tan(x) + 230));
  35.     }
  36.  
  37.     ReleaseDC(hWnd, hDC);
  38. }
Add Comment
Please, Sign In to add comment