From e8c5b3d20261159a1d0276048cc9942d0fe6c4a7 Mon Sep 17 00:00:00 2001 From: Armin <armin.co@hs-bochum.de> Date: Sun, 24 Jan 2021 13:33:52 +0100 Subject: [PATCH] Simulation with Gauss Box --- QPong/Particle.cpp | 2 +- QPong/Utils.cpp | 9 +++++++++ QPong/Utils.hpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/QPong/Particle.cpp b/QPong/Particle.cpp index 71bb4a3..0feee44 100644 --- a/QPong/Particle.cpp +++ b/QPong/Particle.cpp @@ -84,7 +84,7 @@ Particle::Particle(Properties properties, GameOptions &options, Player &playerOn else { // "Simulation" - calculateSchroedingerPotential(m_staticBorders, m_xAt, m_yAt, m_properties.elements()); + calculateGaussBox(m_staticBorders, m_xAt, m_yAt, m_properties.elements()); } fftw_init_threads(); diff --git a/QPong/Utils.cpp b/QPong/Utils.cpp index 2586bcf..b09bf86 100644 --- a/QPong/Utils.cpp +++ b/QPong/Utils.cpp @@ -91,4 +91,13 @@ void calculateSchroedingerPotential(float *potential, double *xAt, double *yAt, { potential[i] = ( pow2(pow2(xAt[i]) + pow2(yAt[i])) ) / 200.0; } +} + +void calculateGaussBox(float *potential, double *xAt, double *yAt, int arrayElements) +{ + constexpr double grow = 2.0; + for (int i{0}; i < arrayElements; ++i) + { + potential[i] = 1.0 / ((exp( -pow2(xAt[i]*grow) + -pow2(yAt[i]*grow))) * 5500.0); + } } \ No newline at end of file diff --git a/QPong/Utils.hpp b/QPong/Utils.hpp index 35a069c..54ecfcb 100644 --- a/QPong/Utils.hpp +++ b/QPong/Utils.hpp @@ -18,5 +18,5 @@ void calculateMomentumViewPositions(float *points, int arraySize); void calculateTriangleIndices(uint32_t *indices, int arraySize); void calculateBorderPotential(float *potential, double *yAt, int arrayElements); void calculateSchroedingerPotential(float *potential, double *xAt, double *yAt, int arrayElements); - +void calculateGaussBox(float *potential, double *xAt, double *yAt, int arrayElemnts); #endif \ No newline at end of file -- GitLab