From b61edcc4949c30a7aadefc8fe4d02c86327334df Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Mon, 24 May 2010 19:35:01 +0000 Subject: [PATCH] Implementation of Projected-Gauss-Seidel LCP solver done git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@323 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- .../lcp/LCPProjectedGaussSeidel.cpp | 19 +++++++++++++------ .../mathematics/lcp/LCPProjectedGaussSeidel.h | 4 ++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.cpp b/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.cpp index 3e57f895..b2914539 100644 --- a/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.cpp +++ b/sources/reactphysics3d/mathematics/lcp/LCPProjectedGaussSeidel.cpp @@ -19,6 +19,7 @@ // Libraries #include "LCPProjectedGaussSeidel.h" +#include using namespace reactphysics3d; @@ -39,9 +40,10 @@ void LCPProjectedGaussSeidel::solve(const Matrix** const J_sp, const Matrix** co uint nbBodies, const Body*** const bodyMapping, std::map bodyNumberMapping, const Vector& b, const Vector& lowLimits, const Vector& highLimits, Vector& lambda) const { lambda = lambdaInit; - double d[] = new double[nbConstraints]; + double d[] = new double[nbConstraints]; // TODO : Avoid those kind of memory allocation here for optimization (allocate once in the object) Body* indexBody1, indexBody2; double deltaLambda; + double lambdaTemp; uint i, iter; Vector* a = new Vector(6)[nbBodies]; // Array that contains nbBodies vector of dimension 6x1 @@ -54,12 +56,15 @@ void LCPProjectedGaussSeidel::solve(const Matrix** const J_sp, const Matrix** co for (i=0; i bodyNumberMapping, - Vector* const a) { + Vector* const a, uint nbBodies) const { uint i; Body* indexBody1, indexBody2; // Init the vector a with zero values - a.initWithValue(0.0); + for (i=0; i bodyNumberMapping, + Vector* const a, uint nbBodies) const ; // Compute the vector a used in the solve() method + public: LCPProjectedGaussSeidel(uint maxIterations); // Constructor virtual ~LCPProjectedGaussSeidel(); // Destructor