I have an assembly of random object that are grouped by some springs and rigid bodies and a custom goal for lines keeping them parallel. Without my goal the simulations solves in around 700 iterations but when I use it it solves also fast but then starts floating in space. I think its because it could not converge for some of the vectors I used in my goal:
So my question is how do I compensate for this behaviour? Because it solves for all lines in the end do I have to set some kind of threshold that would deem the solution as successful? I tried with a simple counter but doesn’t seem to be reasonable.
b1 = b2 = b3 = true;
var angle = Math.Abs(Lim) * Math.PI / 180;
//var c1 = Vector3d.CrossProduct(mVV1, mV1);
var a1 = Vector3d.VectorAngle(mVV1, mV1);
if (Math.Abs(a1) > angle )
{
Move[6] = m12 - m2;
Weighting[6] = Strength;
}
else
{
Move[6] = Vector3d.Zero;
Weighting[6] = 0.0;
b1 = false;
}
var a2 = Vector3d.VectorAngle(mVV2, mV2);
if (Math.Abs(a2) > angle)
{
Move[8] = m32 - m4;
Weighting[8] = Strength;
}
else
{
Move[8] = Vector3d.Zero;
Weighting[8] = 0.0;
b2 = false;
}
var a3 = Vector3d.VectorAngle(mVV3, mV3);
if (Math.Abs(a3) > angle)
{
Move[10] = m52 - m6;
Weighting[10] = Strength;
}
else
{
Move[10] = Vector3d.Zero;
Weighting[10] = 0.0;
b3 = false;
}
if (b1 == false && (b2 == false & b3 == false))
if (b1 == _b1 && (b2 == _b2 && b3 == _b3))
counter++;
// if (counter > 20)
// {
// Move[10] = Move[8] = Move[6] = Vector3d.Zero;
// Weighting[10] = Weighting[8] = Weighting[6] = 0.0;
// }
_b1 = b1;
_b2 = b2;
_b3 = b3;