From 3b25635c1922d95e90d7b4e7e943d7f1c16c2bdd Mon Sep 17 00:00:00 2001 From: Lauchmelder Date: Thu, 9 Dec 2021 22:24:58 +0100 Subject: [PATCH] changed vector field slightly --- src/Application.cpp | 12 +++++++----- src/VectorField.cpp | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index be63b86..fb404b1 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -37,7 +37,7 @@ Application::Application(int width, int height, const char* title) // Construct dummy velocity field // TODO: Remove eventually - int fieldSize = 49; + int fieldSize = 39; double curl1 = -1.0; double curl2 = 1.0; std::vector hori(fieldSize * fieldSize); @@ -51,15 +51,17 @@ Application::Application(int width, int height, const char* title) double realX = -2.0 + (4.0 / (double)fieldSize) * (double)x; double realY = -2.0 + (4.0 / (double)fieldSize) * (double)y; - // hori[y * fieldSize + x] = (realY + 1.0) / sqrt((realX + 1.0) * (realX + 1.0) + (realY + 1.0) * (realY + 1.0)) - (realY - 1.0) / sqrt((realX - 1.0) * (realX - 1.0) + (realY - 1.0) * (realY - 1.0)); - // vert[y * fieldSize + x] = -(realX + 1.0) / sqrt((realX + 1.0) * (realX + 1.0) + (realY + 1.0) * (realY + 1.0)) + (realX - 1.0) / sqrt((realX - 1.0) * (realX - 1.0) + (realY - 1.0) * (realY - 1.0)); + // hori[y * fieldSize + x] = -(realX + 1.0) / sqrt((realX + 1.0) * (realX + 1.0) + (realY + 1.0) * (realY + 1.0)) + (realX - 1.0) / sqrt((realX - 1.0) * (realX - 1.0) + (realY - 1.0) * (realY - 1.0)); + // vert[y * fieldSize + x] = (realY + 1.0) / sqrt((realX + 1.0) * (realX + 1.0) + (realY + 1.0) * (realY + 1.0)) - (realY - 1.0) / sqrt((realX - 1.0) * (realX - 1.0) + (realY - 1.0) * (realY - 1.0)); // hori[y * fieldSize + x] = realY / sqrt(realX * realX + realY * realY); // vert[y * fieldSize + x] = -realX / sqrt(realX * realX + realY * realY); - hori[y * fieldSize + x] = -realY; - vert[y * fieldSize + x] = realX; + // hori[y * fieldSize + x] = -realY; + // vert[y * fieldSize + x] = realX; + hori[y * fieldSize + x] = realY; + vert[y * fieldSize + x] = -realX - 1.0*realY; } } diff --git a/src/VectorField.cpp b/src/VectorField.cpp index f7360d9..350029e 100644 --- a/src/VectorField.cpp +++ b/src/VectorField.cpp @@ -56,8 +56,8 @@ void VectorField::Draw(SDL_Renderer* renderer, const SDL_Rect& targetRect) SDL_RenderDrawLineF(renderer, (double)targetRect.x + cellWidth * (x + 0.5), (double)targetRect.y + cellHeight * (y + 0.5), - (double)targetRect.x + cellWidth * (x + 0.5) + horizontal[y * width + x] / biggestMagnitude * cellWidth, - (double)targetRect.y + cellHeight * (y + 0.5) + vertical[y * width + x] / biggestMagnitude * cellHeight + (double)targetRect.x + cellWidth * (x + 0.5) + horizontal[y * width + x] / biggestMagnitude * cellWidth * 2.5, + (double)targetRect.y + cellHeight * (y + 0.5) + vertical[y * width + x] / biggestMagnitude * cellHeight * 2.5 ); } }