diff --git a/QPong/Particle.cpp b/QPong/Particle.cpp index cc7ff930024fdd7e01619678b443db0a4fa5b5d1..ea20c6993ea4c8265480797b7adabed067ea180d 100644 --- a/QPong/Particle.cpp +++ b/QPong/Particle.cpp @@ -84,7 +84,7 @@ Particle::Particle(Properties properties, GameOptions &options, Player &playerOn else { // "Simulation" - calculateMorseBox(m_staticBorders, m_xAt, m_yAt, m_properties.elements()); + calculateH2Box(m_staticBorders, m_xAt, m_yAt, m_properties.elements()); m_leftBat.moveAway(); m_rightBat.moveAway(); } diff --git a/QPong/Utils.cpp b/QPong/Utils.cpp index 379699e5388fef2662bd53dd4afbe004540d384a..a597a94754c6346b55b49f0ac5c989ff213758ca 100644 --- a/QPong/Utils.cpp +++ b/QPong/Utils.cpp @@ -99,4 +99,34 @@ void calculateMorseBox(float *potential, double *xAt, double *yAt, int arrayElem V *= scalePotential; potential[i] = 1.0 - V; } -} \ No newline at end of file +} + +void calculateGaussBox(float *potential, double *xAt, double *yAt, int arrayElements) +{ + constexpr double grow = 0.1; + constexpr double scalePotential = 1.0; + for (int i{0}; i < arrayElements; ++i) + { + auto x = xAt[i] * grow; + auto y = yAt[i] * grow; + auto d = pow2(x) + pow2(y); + auto V = exp(-d); + V *= scalePotential; + potential[i] = 1.0 - V; + } +} + +void calculateH2Box(float *potential, double *xAt, double *yAt, int arrayElements) +{ + constexpr double grow = 1.0; + constexpr double scalePotential = 0.005; + for (int i{0}; i < arrayElements; ++i) + { + auto x = xAt[i] * grow; + auto y = yAt[i] * grow; + auto d = sqrt(pow2(x) + pow2(y)); + auto V = d; + V *= scalePotential; + potential[i] = V; + } +} diff --git a/QPong/Utils.hpp b/QPong/Utils.hpp index 0bf41768bcc3629d8a572000b04c6bc3794acbfe..53a305ef3b4864b7841dc6d0876d51a47d4383b5 100644 --- a/QPong/Utils.hpp +++ b/QPong/Utils.hpp @@ -18,4 +18,6 @@ void calculateMomentumViewPositions(float *points, int arraySize); void calculateTriangleIndices(uint32_t *indices, int arraySize); void calculateBorderPotential(float *potential, double *xAt, double *yAt, int arrayElements); void calculateMorseBox(float *potential, double *xAt, double *yAt, int arrayElemnts); +void calculateGaussBox(float *potential, double *xAt, double *yAt, int arrayElemnts); +void calculateH2Box(float *potential, double *xAt, double *yAt, int arrayElemnts); #endif \ No newline at end of file