diff --git a/labo01/MatrixBase.h b/labo01/MatrixBase.h index 9cf7b9c..44d5ab4 100644 --- a/labo01/MatrixBase.h +++ b/labo01/MatrixBase.h @@ -23,7 +23,7 @@ namespace gti320 class MatrixBase { protected: - DenseStorage<_Scalar, _Rows* _Cols> m_storage; + DenseStorage<_Scalar, _Rows * _Cols> m_storage; public: diff --git a/labo01/Vector.h b/labo01/Vector.h index f4055d3..2945894 100644 --- a/labo01/Vector.h +++ b/labo01/Vector.h @@ -68,6 +68,7 @@ namespace gti320 { */ Vector &operator=(const Vector &other) { this->m_storage = other.m_storage; + this->m_rows = other.rows(); return *this; } diff --git a/labo_physique/ParticleSimApplication.cpp b/labo_physique/ParticleSimApplication.cpp index 16fc4ab..cdacbbe 100644 --- a/labo_physique/ParticleSimApplication.cpp +++ b/labo_physique/ParticleSimApplication.cpp @@ -553,7 +553,7 @@ void ParticleSimApplication::step(float dt) // implicite. Les nouvelles position sont calculées à partir des position // actuelles m_x et des nouvelles vitesses v_plus. Les nouvelles positions // sont stockées directement dans le vecteur m_x. - + m_x = m_x + dt * v_plus; // Affecte les valeurs calculées dans le vecteurs d'états aux particules du // système diff --git a/labo_physique/ParticleSystem.cpp b/labo_physique/ParticleSystem.cpp index c25b8b7..dd9d44b 100644 --- a/labo_physique/ParticleSystem.cpp +++ b/labo_physique/ParticleSystem.cpp @@ -28,8 +28,11 @@ void ParticleSystem::computeForces() { Particle &p0 = m_particles[s.index0]; Particle &p1 = m_particles[s.index1]; - p0.f = p0.f + (s.k * p0.x); - p1.f = p1.f + (-s.k * p1.x); + Vector distance = p1.x - p0.x; + Vector force = (s.k * (1 - s.l0 / distance.norm())) * distance; + + p0.f = p0.f + force; + p1.f = p1.f - force; } }