Skip to content

Instantly share code, notes, and snippets.

@erwincoumans
erwincoumans / gist:6666160
Last active January 7, 2024 10:28
Example how to create the A matrix and b vector and solve the LCP using Projected Gauss Seidel for Bullet 2.x. Requires Eigen lib and Bullet 2.82. Note that one of the differences between plain projected Gauss Seidel and the Bullet iterative solver is that the friction limits are computed at each iterations, from the related normal force. (This …
//#include "Eigen/Dense"
#include "Eigen/Sparse"
static Eigen::VectorXf Solve_GaussSeidel (Eigen::MatrixXf & A, Eigen::VectorXf & b, Eigen::VectorXf & lo,Eigen::VectorXf & hi,int kMax = 5)
{
//A is a m-n matrix, m rows, n columns
if (A.rows() != b.rows())
return b;
int i, j, n = A.rows();