From: Kirill O. <kir...@gm...> - 2013-03-08 11:58:06
|
Dear Avogadro developers, I want to use Avogadro in my project to visualize molecules and crystal structures. In my project, I'm using Eigen3 library, so I decide to get into Avogadro code and change it to support Eigen3 API. I did step-by-step migration, like described here. http://eigen.tuxfamily.org/dox/Eigen2SupportModes.html and came to stage EIGEN2_SUPPORT_STAGE40_FULL_EIGEN3_STRICTNESS, meaning that new code should follow 100% Eigen3 API, but in old code still function compatible with eigen2 exists ("eigen2_" prefix) I have only one part of code, which is not working like before. computeGeomInfo() in molecule.cpp In Eigen3 library LeastSquares module was excluded, so I should write the code for the fitting by myself. The investigation of the code showed one problematic part. void Molecule::computeGeomInfo() const { ... d->center.setZero(); ... //some code not affecting d->center variable // compute radius and the farthest atom d->radius = std::numeric_limits<double>::min(); foreach (Atom *atom, m_atomList) { double distanceToCenter = (*atom->pos() - d->center).squaredNorm(); //!!! center is Zero if(distanceToCenter > d->radius) { d->radius = distanceToCenter; d->farthestAtom = atom; } } d->radius = sqrt(d->radius); ...... // Calculation of the center after // Calculate the center of the molecule too foreach (Atom *atom, m_atomList) { Vector3d *pos = &(*m_atomPos)[atom->id()]; d->center += *pos; atomPositions[i++] = pos; } d->center /= static_cast<double>(nAtoms); ... I just want to ask some questions. 1) Are you interesting in the contribution (eigen2->eigen3). 2) What should I do with geometry info procedure. Should I change the radius calculations. Best regards, Kirill. |