Changeset 108d38


Ignore:
Timestamp:
May 18, 2010, 3:58:58 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Children:
9bb477, c20eac
Parents:
06f141
Message:

BUGFIX: molecule::DetermineCenterOfAll() was broken for single atom.

  • in case of single atom center would be (nan, nan, nan) due to wrong list treatment.
Location:
molecuilder
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/molecule_geometry.cpp

    r06f141 r108d38  
    109109
    110110  if (ptr->next != end) {   //list not empty?
    111     while (ptr->next != end) {  // continue with second if present
     111    while (ptr->next != end) {
    112112      ptr = ptr->next;
    113113      Num++;
     
    125125Vector * molecule::DetermineCenterOfAll() const
    126126{
    127   atom *ptr = start->next;  // start at first in list
     127  atom *ptr = start;  // start at first in list
    128128  Vector *a = new Vector();
    129   Vector tmp;
    130129  double Num = 0;
    131130
    132131  a->Zero();
    133132
    134   if (ptr != end) {   //list not empty?
    135     while (ptr->next != end) {  // continue with second if present
     133  if (ptr->next != end) {   //list not empty?
     134    while (ptr->next != end) {
    136135      ptr = ptr->next;
    137136      Num += 1.;
    138       tmp = ptr->x;
    139       (*a) += tmp;
     137      (*a) += ptr->x;
    140138    }
    141139    a->Scale(1./Num); // divide through total mass (and sign for direction)
Note: See TracChangeset for help on using the changeset viewer.