added vector fields
This commit is contained in:
parent
5dbcbd6c02
commit
30e130d123
5 changed files with 126 additions and 1 deletions
|
@ -34,6 +34,36 @@ Application::Application(int width, int height, const char* title)
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct dummy velocity field
|
||||
// TODO: Remove eventually
|
||||
int fieldSize = 49;
|
||||
double curl1 = -1.0;
|
||||
double curl2 = 1.0;
|
||||
std::vector<double> hori(fieldSize * fieldSize);
|
||||
std::vector<double> vert(fieldSize * fieldSize);
|
||||
|
||||
for (int y = 0; y < fieldSize; y++)
|
||||
{
|
||||
for (int x = 0; x < fieldSize; x++)
|
||||
{
|
||||
// map internal coords to "real world" coordinates
|
||||
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] = 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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
velocity = VectorField(fieldSize, fieldSize, hori, vert);
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
|
@ -85,5 +115,8 @@ void Application::Render()
|
|||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
|
||||
velocity.Draw(renderer, {10, 10, 790, 790});
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue