diff options
| author | Andrew Guschin <saintruler@gmail.com> | 2020-11-10 01:27:33 +0300 |
|---|---|---|
| committer | Andrew Guschin <saintruler@gmail.com> | 2020-11-10 01:27:33 +0300 |
| commit | aa5790807ad039c1c9db01f7a96f5f643dd56b45 (patch) | |
| tree | 07da8254f9f0ae2e25c4492b1dd98d79db9b9cbc /task05_3D/Guschin/MyForm.h | |
| parent | 73c6ec80c71dd43125b6a9b00dd9e940b827f29f (diff) | |
Добавил третье измерение в 5й задаче
Diffstat (limited to 'task05_3D/Guschin/MyForm.h')
| -rw-r--r-- | task05_3D/Guschin/MyForm.h | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/task05_3D/Guschin/MyForm.h b/task05_3D/Guschin/MyForm.h index 7e76f41..369f2e8 100644 --- a/task05_3D/Guschin/MyForm.h +++ b/task05_3D/Guschin/MyForm.h @@ -10,11 +10,11 @@ namespace Guschin { using namespace System::Drawing; using namespace std; - vec2 Vc; - vec2 V; - vec2 Vc_work, V_work; - mat3 T; - mat3 initT; + vec3 Vc; + vec3 V; + vec3 Vc_work, V_work; + mat4 T; + mat4 initT; public ref class MyForm : public System::Windows::Forms::Form { @@ -75,16 +75,16 @@ namespace Guschin { } System::Void worldRectCalc() { - Vc_work = normalize(T * vec3(Vc, 1.f)); - V_work = mat2(T) * V; + Vc_work = normalize(T * vec4(Vc, 1.f)); + V_work = mat3(T) * V; } - float f(float x) + float f(float x, float z) { - return tan(x); + return x * sin(sqrtf(x * x + z * z)); } - bool f_exists(float x, float delta) + bool f_exists(float x, float z, float delta) { - return fabs(2.f * acos(cos(x)) - Math::PI) > delta; + return true; } private: System::Void MyForm_Resize(System::Object^ sender, System::EventArgs^ e) { @@ -103,15 +103,16 @@ namespace Guschin { float deltaX = V_work.x / Wx; bool hasStart, hasEnd; + float z = Vc_work.z; vec2 start, end; float x, y; start.x = Wcx; x = Vc_work.x; - hasStart = f_exists(x, deltaX); + hasStart = f_exists(x, z, deltaX); if (hasStart) { - y = f(x); + y = f(x, z); start.y = Wcy - (y - Vc_work.y) / V_work.y * Wy; } @@ -121,10 +122,10 @@ namespace Guschin { { end.x = start.x + 1.f; x += deltaX; - hasEnd = f_exists(x, deltaX); + hasEnd = f_exists(x, z, deltaX); if (hasEnd) { - y = f(x); + y = f(x, z); deltaY = (y - Vc_work.y) / V_work.y; end.y = Wcy - deltaY * Wy; } @@ -155,10 +156,10 @@ namespace Guschin { } private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) { - initT = mat3(1.f); + initT = mat4(1.f); T = initT; - Vc = vec2(-2.f, -2.f); - V = vec2(4.f, 4.f); + Vc = vec3(-2.f, -2.f, -2.f); + V = vec3(4.f, 4.f, 4.f); rectCalc(); worldRectCalc(); } @@ -166,18 +167,19 @@ namespace Guschin { System::Void MyForm_KeyDown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e) { float centerX = Vc_work.x + V_work.x / 2; float centerY = Vc_work.y + V_work.y / 2; + float centerZ = Vc_work.z + V_work.z / 2; switch (e->KeyCode) { case Keys::Escape: T = initT; break; case Keys::A: - T = translate(-V_work.x / Wx, 0.f) * T; + T = translate(-V_work.x / Wx, 0.f, 0.f) * T; break; case Keys::Z: - T = translate(-centerX, -centerY) * T; - T = scale(1.1) * T; - T = translate(centerX, centerY) * T; + T = translate(-centerX, -centerY, -centerZ) * T; + T = scale(1.1, 1.1, 1.1) * T; + T = translate(centerX, centerY, centerZ) * T; break; default: break; |