Commit 32b1bbd9 by Maarten L. Hekkelman

combine translate and rotate in a single call

parent 1abf31ff
...@@ -162,6 +162,9 @@ class Atom ...@@ -162,6 +162,9 @@ class Atom
/// \brief Rotate the position of this atom by \a q /// \brief Rotate the position of this atom by \a q
void rotate(Quaternion q); void rotate(Quaternion q);
/// \brief Translate and rotate the position of this atom by \a t and \a q
void translateAndRotate(Point t, Quaternion q);
// for direct access to underlying data, be careful! // for direct access to underlying data, be careful!
const cif::Row getRow() const { return mImpl->mRow; } const cif::Row getRow() const { return mImpl->mRow; }
const cif::Row getRowAniso() const; const cif::Row getRowAniso() const;
...@@ -603,6 +606,9 @@ class Structure ...@@ -603,6 +606,9 @@ class Structure
/// \brief Rotate the coordinates of all atoms in the structure by \a q /// \brief Rotate the coordinates of all atoms in the structure by \a q
void rotate(Quaternion t); void rotate(Quaternion t);
/// \brief Translate and rotate the coordinates of all atoms in the structure by \a t and \a q
void translateAndRotate(Point t, Quaternion q);
const std::vector<Residue> &getNonPolymers() const { return mNonPolymers; } const std::vector<Residue> &getNonPolymers() const { return mNonPolymers; }
const std::vector<Residue> &getBranchResidues() const { return mBranchResidues; } const std::vector<Residue> &getBranchResidues() const { return mBranchResidues; }
......
...@@ -295,12 +295,9 @@ void Atom::AtomImpl::moveTo(const Point &p) ...@@ -295,12 +295,9 @@ void Atom::AtomImpl::moveTo(const Point &p)
if (not mClone) if (not mClone)
{ {
// set_property("Cartn_x", std::to_string(p.getX())); mRow.assign("Cartn_x", std::to_string(p.getX()), false, false);
// set_property("Cartn_y", std::to_string(p.getY())); mRow.assign("Cartn_y", std::to_string(p.getY()), false, false);
// set_property("Cartn_z", std::to_string(p.getZ())); mRow.assign("Cartn_z", std::to_string(p.getZ()), false, false);
mRow.assign("Cartn_x", std::to_string(p.getX()), true);
mRow.assign("Cartn_y", std::to_string(p.getY()), true);
mRow.assign("Cartn_z", std::to_string(p.getZ()), true);
} }
mLocation = p; mLocation = p;
...@@ -453,6 +450,14 @@ void Atom::rotate(Quaternion q) ...@@ -453,6 +450,14 @@ void Atom::rotate(Quaternion q)
location(loc); location(loc);
} }
void Atom::translateAndRotate(Point t, Quaternion q)
{
auto loc = location();
loc += t;
loc.rotate(q);
location(loc);
}
bool Atom::operator==(const Atom &rhs) const bool Atom::operator==(const Atom &rhs) const
{ {
return mImpl == rhs.mImpl or return mImpl == rhs.mImpl or
...@@ -2186,4 +2191,10 @@ void Structure::rotate(Quaternion q) ...@@ -2186,4 +2191,10 @@ void Structure::rotate(Quaternion q)
a.rotate(q); a.rotate(q);
} }
void Structure::translateAndRotate(Point t, Quaternion q)
{
for (auto &a : mAtoms)
a.translateAndRotate(t, q);
}
} // namespace mmcif } // namespace mmcif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment