Code:

classSpring{
private:
double ks;
double kd;
double l0;
int orig, dest;
public:
Spring(int from, int to, double spring_const);
glm::vec3 calculate_spring_force(glm::vec3 xa, glm::vec3 xb, double mass, glm::vec3 velocity);
};

Particle:
Code:

class Particle
{
private:
glm::vec3 position;
glm::vec3 velocity;
glm::vec3 total_force;
std::vector<Spring> springs;
double mass;
bool fixed;
public:
Particle(glm::vec3 pos);
void add_spring(int from, int to, double spring_const);
glm::vec3 get_position()
{
return position;
}
int get_spring_count()
{
springs.size();
}
};
void Particle::add_spring(int from, int to, double spring_const)
{
springs.push_back(Spring(from, to, spring_const));
}

Code:

std::vector<Particle> particles;
int particle_count = 0;
for (size_t i = 0; i < n; i++)
{
for (size_t j = 0; j < n; j++)
{
Particle particle(particle_positions[particle_count]);
for (size_t k = 0; k < conn.cols(); k++)
{
if (some_func(particle_count, k))
{
particle.add_spring(particle_count, k, conn(particle_count, k));
}
}
particles.push_back(particle);
particle_count++;
}
}