diff --git a/QPong/Particle.cpp b/QPong/Particle.cpp index 71bb4a3823826b55dd8218d972e94f8663a89823..0feee44127fe83f56b9e7a8f973f0b4016f84df6 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 2586bcff21c4d71cc0db050ff3a09c3a7119e313..b09bf862a09a075bacf55e76d77a05c8cf329edf 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 35a069ce4f549f47e38bde6b0e2a2b28db017b56..54ecfcbbfb5c6174a874cdea2197ed39fbadbaae 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