( ).

:

(++), . : ( ).
( ).
Google
" "


:

 

 



. 3

1 . 4

2 . 5

2.1 . 6

3 .. 7

4 . 12

5 .. 13

6 . 15

. 17

. 18

.. 19

.1. .. 19

.2. ( my.txt) 27

B.. 29

. 29

 


  ,      ,   , .

- 1960- . . , .

.     , , . .

  , . .

.  (  )   ,      .     .   . (, ).


1

(++), . : ( ).

, , 50 .

, . . . , .

, .


2

, . , .

66 . my.txt (. .2). , , . .

, . , . . , , , .

. .

, .

: . :

. , , .

, , , .

2.1 .

. :

struct coord_3d { //

float x;

float y;

float z;

} *coor_3d, *copycoor_3d;

struct coord_2d { //

float sx;

float sy;

} *coor_2d;

struct sctlinks { // (, , one two)

int one;

int two;

} *links;

struct sctmatrix { //

float x;

float y;

float z;

} matrix[3];

:

1.    

2.     -.

3.     .

4.     .

5.     .

3

++. .

Visual Studio 2005.

, .. . , .

- . .

.

- .

.

:



 


:

 


i = 0; i < c_number; i++

 


i

 


coor_2d[i].sx coor_2d[i].sy , coor_3d[i].x , coor_3d[i].y, coor_3d[i].z , dist .

:

 


i = 0; i < links_number; i++

 


i

 



.

 



4

Microsoft Visual Studio 2005. , . , , , .

. . . , .


5

. , .

. .

. , . . , . . , .

, . , .

, .

.

6

, . - . .

-. . :

Num1

Num2

Num3

Num4

. . F1 F2. 1 89. 90, . 90 , . , , .

+ -. . . F3 F4. 1,01 1,99. . , .

, . - .

, - . :


, . , .

, , . .


1.     .. . 2010 .

2.     MSDN.

3.     .

4.     .


.1.

#include "stdafx.h"

#include "KG.h"

#define MAX_LOADSTRING 100

////////////////////////////////////////////////////////////////////////////

int wmId, wmEvent;

PAINTSTRUCT ps;

HDC hdc;

HWND hWnd;

HPEN hPen;

FILE * my;

int i, j;

int c_number; //

int links_number; //

int dist = 1500; //

float Pi = 3.14159265358979323846;

int flag;

int alpha; //

float k; //

char buf[1], buf1[1], buf3[1], buf4[4]; //

LPCWSTR str, str1, str2, str3; // itoa char

int a = 1, b = 0, c = 0, d = 1;

struct coord_3d { //

float x;

float y;

float z;

} *coor_3d, *copycoor_3d;

struct coord_2d { //

float sx;

float sy;

} *coor_2d;

struct sctlinks { // (, , one two)

int one;

int two;

} *links;

struct sctmatrix { //

float x;

float y;

float z;

} matrix[3];

////////////////////////////////////////////////////////////////////////////

// Global Variables:

HINSTANCE hInst; // current instance

TCHAR szTitle[MAX_LOADSTRING]; // The title bar text

TCHAR szWindowClass[MAX_LOADSTRING]; // the window class name

// Forward declarations of functions included in this code module:

ATOM MyRegisterClass(HINSTANCE hInstance);

BOOL InitInstance(HINSTANCE, int);

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY _tWinMain(HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPTSTR lpCmdLine,

int nCmdShow)

{

UNREFERENCED_PARAMETER(hPrevInstance);

UNREFERENCED_PARAMETER(lpCmdLine);

// TODO: Place code here.

MSG msg;

HACCEL hAccelTable;

// Initialize global strings

LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);

LoadString(hInstance, IDC_KG, szWindowClass, MAX_LOADSTRING);

MyRegisterClass(hInstance);

// Perform application initialization:

if (!InitInstance (hInstance, nCmdShow))

{

return FALSE;

}

hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_KG));

// Main message loop:

while (GetMessage(&msg, NULL, 0, 0))

{

if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

}

return (int) msg.wParam;

}

ATOM MyRegisterClass(HINSTANCE hInstance)

{

WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;

wcex.lpfnWndProc = WndProc;

wcex.cbClsExtra = 0;

wcex.cbWndExtra = 0;

wcex.hInstance = hInstance;

wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_KG));

wcex.hCursor = LoadCursor(NULL, IDC_ARROW);

wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);

wcex.lpszMenuName = MAKEINTRESOURCE(IDC_KG);

wcex.lpszClassName = szWindowClass;

wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

return RegisterClassEx(&wcex);

}

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)

{

hInst = hInstance; // Store instance handle in our global variable

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,

CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

if (!hWnd)

{

return FALSE;

}

ShowWindow(hWnd, nCmdShow);

UpdateWindow(hWnd);

return TRUE;

}

void draw() { //

for(i = 0; i < c_number; i++) { //

coor_2d[i].sx = coor_3d[i].x * dist/(coor_3d[i].z + dist);

coor_2d[i].sy = coor_3d[i].y * dist/(coor_3d[i].z + dist);

}

InvalidateRect(hWnd, NULL, TRUE);

UpdateWindow(hWnd);

hdc = BeginPaint(hWnd, &ps);

TextOut(hdc, 10, 10, L"alpha:", 6); //

str = (LPCWSTR)itoa(b, buf, 10);

TextOut(hdc, 60, 10, str, strlen(buf));

str1 = (LPCWSTR)itoa(a, buf1, 10);

TextOut(hdc, 68, 10, str1, strlen(buf1));

//

TextOut(hdc, 85, 10, L"k: 1.", 5);

str2 = (LPCWSTR)itoa(c, buf3, 10);

TextOut(hdc, 111, 10, str2, strlen(buf3));

str3 = (LPCWSTR)itoa(d, buf4, 10);

TextOut(hdc, 120, 10, str3, strlen(buf4));

//hPen = CreatePen(PS_DOT,1,RGB(0,60,255)); // PS_SOLD -

//SelectObject(hdc, hPen);

for(i = 0; i < links_number; i++) { //

MoveToEx(hdc, coor_2d[links[i].one].sx, coor_2d[links[i].one].sy, NULL);

LineTo(hdc, coor_2d[links[i].two].sx, coor_2d[links[i].two].sy);

}

EndPaint(hWnd, &ps);

}

void spinmatrix(int alpha, int axis) { // "alpha" "axis"

float radian;

radian = (alpha * Pi) / 180;

if(axis == 1) { // X

matrix[0].x = 1;

matrix[0].y = 0;

matrix[0].z = 0;

matrix[1].x = 0;

matrix[1].y = cos(radian);

matrix[1].z = (-1)*sin(radian);

matrix[2].x = 0;

matrix[2].y = sin(radian);

matrix[2].z = cos(radian);

} else

if(axis == 2) { // Y

matrix[0].x = cos(radian);

matrix[0].y = 0;

matrix[0].z = sin(radian);

matrix[1].x = 0;

matrix[1].y = 1;

matrix[1].z = 0;

matrix[2].x = (-1)*sin(radian);

matrix[2].y = 0;

matrix[2].z = cos(radian);

}

}

void scalematrix(float k, int type) { // k 砠

if(type == 1) { //

matrix[0].x = k;

matrix[0].y = 0;

matrix[0].z = 0;

matrix[1].x = 0;

matrix[1].y = k;

matrix[1].z = 0;

matrix[2].x = 0;

matrix[2].y = 0;

matrix[2].z = k;

} else

if(type == 2) { //

matrix[0].x =1/k;

matrix[0].y = 0;

matrix[0].z = 0;

matrix[1].x = 0;

matrix[1].y = 1/k;

matrix[1].z = 0;

matrix[2].x = 0;

matrix[2].y = 0;

matrix[2].z = 1/k;

}

}

void multiply() { //

copycoor_3d = new coord_3d[c_number]; // "c_number"

flag = 1;

for(i = 0; i < c_number; i++) {

copycoor_3d[i].x = ((coor_3d[i].x - 675) * matrix[0].x + (coor_3d[i].y - 362) * matrix[1].x + (coor_3d[i].z - 150) * matrix[2].x) + 675;

copycoor_3d[i].y = ((coor_3d[i].x - 675) * matrix[0].y + (coor_3d[i].y - 362) * matrix[1].y + (coor_3d[i].z - 150) * matrix[2].y) + 362;

copycoor_3d[i].z = ((coor_3d[i].x - 675) * matrix[0].z + (coor_3d[i].y - 362) * matrix[1].z + (coor_3d[i].z - 150) * matrix[2].z) + 150;

if((copycoor_3d[i].x < 0) || (copycoor_3d[i].y < 0)) {

flag = 0; //

}

}

if(flag == 1) {

for(i = 0; i < c_number; i++) {

coor_3d[i].x = copycoor_3d[i].x;

coor_3d[i].y = copycoor_3d[i].y;

coor_3d[i].z = copycoor_3d[i].z;

}

}

}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

{

switch (message)

{

case WM_KEYDOWN:

switch (wParam) {

////////////////////////////////////////////////////////////////////////////

case VK_UP: //

spinmatrix(alpha, 1); //

multiply(); //

draw(); //

break;

case VK_DOWN: //

spinmatrix(-alpha, 1); //

multiply(); //

draw(); //

break;

case VK_LEFT: //

spinmatrix(alpha, 2); //

multiply(); //

draw(); //

break;

case VK_RIGHT: //

spinmatrix(-alpha, 2); //

multiply(); //

draw(); //

break;

case VK_ADD: // +

scalematrix(k, 1); // -

multiply(); //

draw(); //

break;

case VK_SUBTRACT: // -

scalematrix(k, 2); // -

multiply(); //

draw(); //

break;

case VK_F1: //

if(alpha < 89){

alpha++;

}

if(alpha > 9) {

b = alpha/10;

a = alpha%10;

}

else {

a = alpha;

b = 0;

}

draw();

break;

case VK_F2: //

if(alpha > 1) {

alpha--;

if(alpha > 9) {

b = alpha/10;

a = alpha%10;

}

else {

a = alpha;

b = 0;

}

draw();

}

break;

case VK_F3: //

if((k >= 1) &&((c < 9) || (d < 9))) {

k = k + 0.01;

c = k*10 - 10;

d = (int)(k * 100) % 10;

draw();

}

break;

case VK_F4: //

if((k > 1) &&((c <= 9) || (d <= 9))) {

k = k - 0.01;

c = k*10 - 10;

d = (int)(k * 100) % 10;

draw();

}

break;

case VK_NUMPAD1: // Num 1

spinmatrix(alpha, 2); //

multiply(); //

spinmatrix(-alpha, 1); //

multiply(); //

draw(); //

break;

case VK_NUMPAD3: // Num 3

spinmatrix(-alpha, 2); //

multiply(); //

spinmatrix(-alpha, 1); //

multiply(); //

draw(); //

break;

case VK_NUMPAD4: // Num 4

spinmatrix(alpha, 2); //

multiply(); //

spinmatrix(alpha, 1); //

multiply(); //

draw(); //

break;

case VK_NUMPAD6: // Num 6

spinmatrix(-alpha, 2); //

multiply(); //

spinmatrix(alpha, 1); //

multiply(); //

draw(); //

break;

////////////////////////////////////////////////////////////////////////////

break;

}

case WM_COMMAND:

wmId = LOWORD(wParam);

wmEvent = HIWORD(wParam);

// Parse the menu selections:

switch (wmId)

{

case IDM_about:

DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);

break;

case IDM_EXIT:

DestroyWindow(hWnd);

break;

////////////////////////////////////////////////////////////////////////////

case ID_FILE_VIEW: //

alpha = 1;

k = 1.01;

my = fopen("my.txt", "r");

if(my != NULL) { // coor_3d[c_number]

fscanf(my, "%d ", &c_number);

coor_3d = new coord_3d[c_number]; // "c_number"

coor_2d = new coord_2d[c_number]; // "c_number"

for(i = 0; i < c_number; i++){

fscanf(my, "%f %f %f ", &coor_3d[i].x, &coor_3d[i].y, &coor_3d[i].z);

}

}

fscanf(my, "%d ", &links_number); //

links = new sctlinks[links_number]; // "links_number"

for(i = 0; i < links_number; i++){

fscanf(my, "%d %d ", &links[i].one, &links[i].two);

}

fclose(my);

draw(); //

break;

////////////////////////////////////////////////////////////////////////////

case ID_FILE_ANIMATION: //

for(j = 1; j < 200; j++){

spinmatrix(-3, 2); //

multiply(); //

scalematrix(1.01, 2); // -

multiply(); //

spinmatrix(2, 1); //

multiply(); //

draw(); //

j++;

Sleep(20);

}

for(j = 1; j < 200; j++){

spinmatrix(-2, 2); //

multiply(); //

scalematrix(1.01, 1); // -

multiply(); //

spinmatrix(-3, 1); //

multiply(); //

draw(); //

j++;

Sleep(20);

}

break;

////////////////////////////////////////////////////////////////////////////

default:

return DefWindowProc(hWnd, message, wParam, lParam);

}

break;

case WM_PAINT: //

ShowWindow(hWnd,SW_MAXIMIZE); //

break;

case WM_DESTROY:

PostQuitMessage(0);

break;

default:

return DefWindowProc(hWnd, message, wParam, lParam);

}

return 0;

}

// Message handler for about box.

INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)

{

UNREFERENCED_PARAMETER(lParam);

switch (message)

{

case WM_INITDIALOG:

return (INT_PTR)TRUE;

case WM_COMMAND:

if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)

{

EndDialog(hDlg, LOWORD(wParam));

return (INT_PTR)TRUE;

}

break;

}

return (INT_PTR)FALSE;

}

.2. ( my.txt)


66

432 301 53

481 301 53

481 382 53

868 382 53

868 301 53

917 301 53

917 479 53

432 479 53

432 301 246

481 301 246

481 382 246

868 382 246

868 301 246

917 301 246

917 479 246

432 479 246

481 382 182

481 220 182

868 220 182

868 382 182

481 220 246

868 220 246

481 350 53

868 350 53

481 350 182

868 350 182

675 382 182

675 220 182

675 220 246

675 382 246

610 382 53

610 350 53

610 350 182

739 382 53

739 350 53

739 350 182

610 382 182

739 382 182

432 495 53

449 495 53

449 479 53

432 495 69

449 495 69

432 479 69

449 479 69

900 479 53

900 495 53

917 495 53

900 495 69

900 479 69

917 479 69

917 495 69

432 495 246

449 495 246

449 479 246

432 495 230

432 479 230

449 479 230

449 495 230

900 479 246

900 495 246

917 495 246

900 495 230

900 479 230

917 479 230

917 495 230

91

0 1

0 7

1 2

2 3

3 4

4 5

5 6

6 7

0 8

8 9

9 1

8 15

15 7

9 10

9 12

2 10

10 11

11 3

11 12

12 13

12 4

13 5

13 14

14 15

14 6

16 17

17 18

18 19

16 19

17 20

20 9

20 21

21 18

21 12

22 23

22 24

24 24

24 25

25 23

26 27

27 28

28 29

29 26

30 31

31 32

33 34

34 35

32 36

35 37

36 30

37 33

7 38

40 39

38 41

39 42

38 39

41 42

41 43

42 44

43 44

44 40

45 46

46 47

6 47

46 48

47 51

48 51

48 49

50 51

45 49

49 50

15 52

54 53

56 55

57 58

52 53

53 58

55 58

52 55

54 57

56 57

59 60

63 62

14 61

64 65

60 61

61 65

62 65

60 62

59 63

63 64



B

B.1

B.2

.3


B.4


( ). z3rg
17.2.2016, 2:00
17.2.2016, 2:00
  (zip - application/zip)
1 ( )
2437
140
V