-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGYPERBOLA.cpp
More file actions
72 lines (62 loc) · 1.45 KB
/
GYPERBOLA.cpp
File metadata and controls
72 lines (62 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "GYPERBOLA.h"
void GYPERBOLA::plot(HDC hdc, int xView, int yView)
{
HPEN hPen = NULL;
int i, y;
TCHAR Buf[10];
double k = 10000.0;
// Ðèñóåì îñè êîîðäèíàò
Line(hdc, 0, yView / 2 - 120, 0, -(yView / 2 - 120)); // îñü Y
Line(hdc, -(xView / 2 - 40), 0, xView / 2 - 40, 0); // îñü X
MoveToEx(hdc, 0, 0, NULL); // ïåðåìåùàåìñÿ â íà÷àëî êîîðäèíàò
// Ñîçäàíèå êðàñíîãî ïåðà
hPen = CreatePen(1, 4, RGB(255, 25, 0));
SelectObject(hdc, hPen);
bool flag = false;
// Ãèïåðáîëà
for (i = 1; i < xView / 2 - 40; i++)
{
y = (int)(k / i);
if (y < (yView / 2 - 120))
{
if (!flag)
{
flag = true;
MoveToEx(hdc, i, (int)y, NULL);
}
LineTo(hdc, i, (int)y);
}
}
flag = false;
for (i = -1; i > -(xView / 2 - 40); i--)
{
y = (int)(k / i);
if (y > -(yView / 2 - 120))
{
if (!flag)
{
flag = true;
MoveToEx(hdc, i, (int)y, NULL);
}
LineTo(hdc, i, (int)y);
}
}
// Äåëàåì ïåðî ñíîâà ÷åðíûì
hPen = CreatePen(1, 1, RGB(0, 0, 0));
SelectObject(hdc, hPen);
// Íàíîñèì äåëåíèÿ
MoveToEx(hdc, 0, 0, NULL);
for (i = yView / 2 - 120; i > -(yView / 2 - 120); i -= 50)
{
Line(hdc, -3, i, 3, i);
_stprintf_s(Buf, L"%4.2f", (float)i);
TextOut(hdc, -5, i, Buf, (int)_ftcslen(Buf));
}
for (i = -(xView / 2 - 40) / 90 * 90; i < (xView / 2 - 40) / 90 * 90; i += 90)
{
Line(hdc, i, 3, i, -3);
_stprintf_s(Buf, L"%4.2f", (float)i);
TextOut(hdc, i - 5, -5, Buf, (int)_ftcslen(Buf));
}
DeleteObject(hPen);
}