Antonio Martini wrote:
a rigid frame can be extracted much faster by using a QR approach. see also figure 2 of :
http://www-evasion.imag.fr/Publications ... /NPF05.pdfthis method is also described in the Physics Based Animation book of Erleben if i remember it correctly.
Thanks the the link, i didn't knew about it.
QR decomposition seen interesting, but as noted in paper, there's a bias depending on vertex order, that can be a problem for resting bodies, a bias is already introduced by the solver (in the 'Bunny', if friction is not set >0.9, it never come rest due to constraints order bias).
Now for speed, polar decomposition is actually quit fast, that's O(vertices) to build the matrix, cost shared by QR decomposition, (though
the O of QR may be faster), then the decomposition itself (Higham's method):
Code:
static inline void PolarDecompose( const btMatrix3x3& m,
btMatrix3x3& q,
btMatrix3x3& s)
{
static const btScalar half=(btScalar)0.5;
static const btScalar accuracy=(btScalar)0.00001;
static const int maxiterations=64;
btScalar det=m.determinant();
if(!btFuzzyZero(det))
{
q=m;
for(int i=0;i<maxiterations;++i)
{
q=Mul(Add(q,Mul(q.adjoint(),1/det).transpose()),half);
const btScalar ndet=q.determinant();
if(Sq(ndet-det)>accuracy) det=ndet; else break;
}
s=q.transpose()*m;
s=Mul(Add(s,s.transpose()),(btScalar)0.5);
}
else
{
q.setIdentity();
s.setIdentity();
}
}
usually stop after ~12 iterations, and there is way the accelerate it further via a scaling factor (and better implementation...

).