Skip to content

Commit

Permalink
Merge pull request #2168 from ghutchis/fabs-in-builder
Browse files Browse the repository at this point in the history
Prefer std::fabs resolves build problem on mac-current
  • Loading branch information
ghutchis committed Apr 9, 2020
2 parents 7d810dc + ef7e96e commit dcbbf55
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/builder.cpp
Expand Up @@ -79,9 +79,9 @@ namespace OpenBabel
{
bool hasAllZeroCoords = true;
for (std::size_t i = 0; i < coords.size(); ++i) {
if (std::abs(coords[i].x()) > 10e-8 ||
std::abs(coords[i].y()) > 10e-8 ||
std::abs(coords[i].z()) > 10e-8) {
if (std::fabs(coords[i].x()) > 10e-8 ||
std::fabs(coords[i].y()) > 10e-8 ||
std::fabs(coords[i].z()) > 10e-8) {
hasAllZeroCoords = false;
break;
}
Expand Down Expand Up @@ -186,9 +186,9 @@ namespace OpenBabel
tokenize(vs, buffer);
if (vs.size() == 4) { // XYZ coordinates
vector3 coord(atof(vs[1].c_str()), atof(vs[2].c_str()), atof(vs[3].c_str()));
if (std::abs(coord.x()) > 10e-8 ||
std::abs(coord.y()) > 10e-8 ||
std::abs(coord.z()) > 10e-8)
if (std::fabs(coord.x()) > 10e-8 ||
std::fabs(coord.y()) > 10e-8 ||
std::fabs(coord.z()) > 10e-8)
hasAllZeroCoords = false;
coords.push_back(coord);
} else if (vs.size() == 1) { // SMARTS pattern
Expand Down Expand Up @@ -310,10 +310,10 @@ namespace OpenBabel
if (bond2 == VZero || v1 == VZero) {
vector3 vrand;
vrand.randomUnitVector();
double angle = fabs(acos(dot(bond1, vrand)) * RAD_TO_DEG);
double angle = std::fabs(acos(dot(bond1, vrand)) * RAD_TO_DEG);
while (angle < 45.0 || angle > 135.0) {
vrand.randomUnitVector();
angle = fabs(acos(dot(bond1, vrand)) * RAD_TO_DEG);
angle = std::fabs(acos(dot(bond1, vrand)) * RAD_TO_DEG);
}
// there is no a-2 atom
v1 = cross(bond1, vrand); // so find a perpendicular, given the random vector (this doesn't matter here)
Expand Down Expand Up @@ -368,7 +368,7 @@ namespace OpenBabel
v1 = v1.normalize();

if (atom->GetHyb() == 2)
newbond = v1;
newbond = v1;
else if (atom->GetHyb() == 3) {
v2 = cross(bond1, bond2); // find the perpendicular
v2.normalize();
Expand All @@ -381,10 +381,10 @@ namespace OpenBabel
* whether PClF4 would be more likely to have an equatorial or axial Cl-P bond */
vector3 vrand;
vrand.randomUnitVector();
double angle = fabs(acos(dot(bond1, vrand)) * RAD_TO_DEG);
double angle = std::fabs(acos(dot(bond1, vrand)) * RAD_TO_DEG);
while (angle < 45.0 || angle > 135.0) {
vrand.randomUnitVector();
angle = fabs(acos(dot(bond1, vrand)) * RAD_TO_DEG);
angle = std::fabs(acos(dot(bond1, vrand)) * RAD_TO_DEG);
}
v1 = cross(bond1, vrand);
v1 = v1.normalize();
Expand Down Expand Up @@ -810,10 +810,10 @@ namespace OpenBabel
else
secondDir.randomUnitVector(); // pick something at random
// but not too shallow, or the cross product won't work well
double angle = fabs(acos(dot(firstDir, secondDir)) * RAD_TO_DEG);
double angle = std::fabs(acos(dot(firstDir, secondDir)) * RAD_TO_DEG);
while (angle < 45.0 || angle > 135.0) {
secondDir.randomUnitVector();
angle = fabs(acos(dot(firstDir, secondDir)) * RAD_TO_DEG);
angle = std::fabs(acos(dot(firstDir, secondDir)) * RAD_TO_DEG);
}
// Now we find a perpendicular vector to the fragment
crossdir = cross(firstDir, secondDir);
Expand Down

0 comments on commit dcbbf55

Please sign in to comment.