Skip to content

Commit

Permalink
+ fix possible problems with roundoff errors of SbRotation
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Feb 6, 2016
1 parent 1324575 commit c30031f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Gui/ManualAlignment.cpp
Expand Up @@ -688,7 +688,15 @@ void ManualAlignment::setViewingDirections(const Base::Vector3d& view1, const Ba
SbRotation rot2;
SbVec3f up(0.0f, 1.0f, 0.0f);
rot.multVec(up, up);
rot2.setValue(up, SbVec3f(up1.x, up1.y, up1.z));

// avoid possible problems with roundoff errors
SbVec3f upDir(up1.x, up1.y, up1.z);
float dot = up.dot(upDir);
if (dot < -0.99f) {
up = -upDir;
}

rot2.setValue(up, upDir);
myViewer->getViewer(0)->getSoRenderManager()->getCamera()->orientation.setValue(rot * rot2);
myViewer->getViewer(0)->viewAll();
}
Expand All @@ -700,7 +708,15 @@ void ManualAlignment::setViewingDirections(const Base::Vector3d& view1, const Ba
SbRotation rot2;
SbVec3f up(0.0f, 1.0f, 0.0f);
rot.multVec(up, up);
rot2.setValue(up, SbVec3f(up2.x, up2.y, up2.z));

// avoid possible problems with roundoff errors
SbVec3f upDir(up2.x, up2.y, up2.z);
float dot = up.dot(upDir);
if (dot < -0.99f) {
up = -upDir;
}

rot2.setValue(up, upDir);
myViewer->getViewer(1)->getSoRenderManager()->getCamera()->orientation.setValue(rot * rot2);
myViewer->getViewer(1)->viewAll();
}
Expand Down

0 comments on commit c30031f

Please sign in to comment.