Skip to content
Snippets Groups Projects
Commit c9f6e7e2 authored by Armin Co's avatar Armin Co
Browse files

H2

parent db35df0a
No related merge requests found
...@@ -84,7 +84,7 @@ Particle::Particle(Properties properties, GameOptions &options, Player &playerOn ...@@ -84,7 +84,7 @@ Particle::Particle(Properties properties, GameOptions &options, Player &playerOn
else else
{ {
// "Simulation" // "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_leftBat.moveAway();
m_rightBat.moveAway(); m_rightBat.moveAway();
} }
......
...@@ -100,3 +100,33 @@ void calculateMorseBox(float *potential, double *xAt, double *yAt, int arrayElem ...@@ -100,3 +100,33 @@ void calculateMorseBox(float *potential, double *xAt, double *yAt, int arrayElem
potential[i] = 1.0 - V; potential[i] = 1.0 - V;
} }
} }
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;
}
}
...@@ -18,4 +18,6 @@ void calculateMomentumViewPositions(float *points, int arraySize); ...@@ -18,4 +18,6 @@ void calculateMomentumViewPositions(float *points, int arraySize);
void calculateTriangleIndices(uint32_t *indices, int arraySize); void calculateTriangleIndices(uint32_t *indices, int arraySize);
void calculateBorderPotential(float *potential, double *xAt, double *yAt, int arrayElements); void calculateBorderPotential(float *potential, double *xAt, double *yAt, int arrayElements);
void calculateMorseBox(float *potential, double *xAt, double *yAt, int arrayElemnts); 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 #endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment