diff --git a/App/GameLayer.cpp b/App/GameLayer.cpp index 0fd7b14b3433d8653d8fc99b8b6999acaf2fd39e..e65120753642cd4eddfe8eb4d946bf1cecc13425 100644 --- a/App/GameLayer.cpp +++ b/App/GameLayer.cpp @@ -177,9 +177,9 @@ void QPong::GameLayer::reset() const int xRand = rand() % 64; const int yRand = rand() % 32; int positive = rand() % 2; - m_properties.momentum.x = (1.0f - (2.0f * positive)) * (1.0 + static_cast<float>(xRand) / 120.0f); + m_properties.momentum.x = (1.0f - (2.0f * positive)) * (1.0 + static_cast<float>(xRand) / 120.0f) / 20.0; positive = rand() % 2; - m_properties.momentum.y = (1.0f - (2.0f * positive)) * (1.0 + static_cast<float>(yRand) / 120.0f); + m_properties.momentum.y = (1.0f - (2.0f * positive)) * (1.0 + static_cast<float>(yRand) / 120.0f) / 20.0; } m_options.game = m_gaming; m_options.absorbtionEnabled = m_gaming; @@ -278,14 +278,14 @@ void QPong::GameLayer::onGuiRender() { // GUI settings for the particle ImGui::Begin("Particle Settings"); - ImGui::DragFloat2("Start Position", glm::value_ptr(m_properties.position), 0.01f, -1.0f, 1.0f); + ImGui::DragFloat2("Start Position", glm::value_ptr(m_properties.position), 0.025f, -0.8f, 0.8f); // Select initial momentum for particle at restart - ImGui::DragFloat2("Momentum [x,y]", glm::value_ptr(m_properties.momentum), 0.01f, -3.0f, 3.0f); + ImGui::DragFloat2("Momentum [x,y]", glm::value_ptr(m_properties.momentum), 0.001f, -0.1f, 0.1f); ImGui::Checkbox("Random Momentum", &m_randomMomentum); float sharpness = m_properties.sharpness; - if (ImGui::DragFloat("Sharpness", &sharpness, 1.0f, 5.0f, 1000.0f)) + if (ImGui::DragFloat("Sharpness", &sharpness, 5.0f, 5.0f, 1000.0f)) { m_properties.sharpness = sharpness; } diff --git a/QPong/Particle.cpp b/QPong/Particle.cpp index 51c22d2d378f4a81d5b208f39d96481b2803565d..3673b87c7796b3c28ee00b4c5d6b7b2835ba5803 100644 --- a/QPong/Particle.cpp +++ b/QPong/Particle.cpp @@ -158,8 +158,8 @@ void Particle::initialiseParticleMomentum() constexpr std::complex<double> ci{0.0, 1.0}; // complex number const double hbar = m_properties.hbar; const double A0 = m_properties.startValue; - const double px0 = m_properties.momentum.x / 20.0; - const double py0 = m_properties.momentum.y / 20.0; + const double px0 = m_properties.momentum.x; + const double py0 = m_properties.momentum.y; const double x0 = m_properties.position.x; const double y0 = m_properties.position.y; const double lambda = m_properties.sharpness; diff --git a/QPong/Utils.cpp b/QPong/Utils.cpp index b09bf862a09a075bacf55e76d77a05c8cf329edf..7fa3285889b20adf1d55d0d7f29ad7c96584ca00 100644 --- a/QPong/Utils.cpp +++ b/QPong/Utils.cpp @@ -95,9 +95,16 @@ void calculateSchroedingerPotential(float *potential, double *xAt, double *yAt, void calculateGaussBox(float *potential, double *xAt, double *yAt, int arrayElements) { - constexpr double grow = 2.0; + constexpr double grow = 0.1; + constexpr double scalePotential = 1.0; for (int i{0}; i < arrayElements; ++i) { - potential[i] = 1.0 / ((exp( -pow2(xAt[i]*grow) + -pow2(yAt[i]*grow))) * 5500.0); + auto x = xAt[i] * grow; + auto y = yAt[i] * grow; + auto d = sqrt(pow2(x) + pow2(y)); + // V(x) = 1 / cosh^2(x) ~= 1 / (1/2 * (cosh(2x)+1)) + auto V = 1.0 / ( 0.5 * (cosh(2.0 * d) + 1.0)); + V *= scalePotential; + potential[i] = 1.0 - V; } } \ No newline at end of file