normalize cos and sin when there is numerical error, which does happen sometimes when composing two rotations
parent
f81519b046
commit
e2728184b9
|
@ -100,8 +100,6 @@ namespace gtsam {
|
||||||
return !(indices_.find(key)==indices_.end());
|
return !(indices_.find(key)==indices_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** check whether a variable is a singleton, i.e. it only involve*/
|
|
||||||
|
|
||||||
/** remove singleton variables and the related factors */
|
/** remove singleton variables and the related factors */
|
||||||
std::pair<FactorGraph<Factor>, std::set<Symbol> > removeSingletons();
|
std::pair<FactorGraph<Factor>, std::set<Symbol> > removeSingletons();
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,11 @@ namespace gtsam {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
Rot2 Rot2::fromCosSin(double c, double s) {
|
Rot2 Rot2::fromCosSin(double c, double s) {
|
||||||
if (fabs(c * c + s * s - 1.0) > 1e-9) throw std::invalid_argument(
|
if (fabs(c * c + s * s - 1.0) > 1e-9) {
|
||||||
"Rot2::fromCosSin: needs cos/sin pair");
|
double norm_cs = sqrt(c*c + s*s);
|
||||||
|
c = c/norm_cs;
|
||||||
|
s = s/norm_cs;
|
||||||
|
}
|
||||||
return Rot2(c, s);
|
return Rot2(c, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue