Skip to content

Commit

Permalink
chiral_abs_volume: avoid nan
Browse files Browse the repository at this point in the history
Chiral volume may become NaN in come cases. An example is the current PRO's chir_2, which will be fixed by MonomerLibrary/monomers#38
  • Loading branch information
keitaroyam authored Dec 11, 2023
1 parent b8ba5a5 commit 6581233
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/gemmi/chemcomp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ inline double chiral_abs_volume(double bond1, double bond2, double bond3,
x -= cosine * cosine;
y *= cosine;
}
return mult * std::sqrt(x + y);
return mult * std::sqrt(std::max(0., x + y));
}

inline double Restraints::chiral_abs_volume(const Restraints::Chirality& ch) const {
Expand Down

0 comments on commit 6581233

Please sign in to comment.