Don't falsely detect inconsistent systems with small angle constraints.

This commit is contained in:
Jonathan Westhues 2015-06-08 11:19:29 -07:00
parent 403d3c04d2
commit ba8202d54a

View File

@ -628,8 +628,15 @@ void ConstraintBase::GenerateReal(IdList<Equation,hEquation> *l) {
if(type == ANGLE) {
// The direction cosine is equal to the cosine of the
// specified angle
Expr *rads = exA->Times(Expr::From(PI/180));
AddEq(l, c->Minus(rads->Cos()), 0);
Expr *rads = exA->Times(Expr::From(PI/180)),
*rc = rads->Cos();
double arc = fabs(rc->Eval());
// avoid false detection of inconsistent systems by gaining
// up as the difference in dot products gets small at small
// angles; doubles still have plenty of precision, only
// problem is that rank test
Expr *mult = Expr::From(arc > 0.99 ? 0.01/(1.00001 - arc) : 1);
AddEq(l, (c->Minus(rc))->Times(mult), 0);
} else {
// The dot product (and therefore the direction cosine)
// is equal to zero, perpendicular.