Changeset 8e52aa for molecuilder


Ignore:
Timestamp:
Sep 9, 2008, 3:32:16 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
55ebd0
Parents:
79cd79
Message:

BUGFIX: Normalize() would try to normalize a zero vector which ended NaN.

We only normalize if vector is non-zero in magnitude.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/vector.cpp

    r79cd79 r8e52aa  
    154154  for (int i=NDIM;i--;)
    155155    res += this->x[i]*this->x[i];
    156   res = 1./sqrt(res);
     156  if (fabs(res) > MYEPSILON)
     157    res = 1./sqrt(res);
    157158  Scale(&res);
    158159};
Note: See TracChangeset for help on using the changeset viewer.