| 56 | 
  | 
     | 
| 57 | 
  | 
    Vector3d r21 = pos1 - pos2; | 
| 58 | 
  | 
    Vector3d r32 = pos2 - pos3; | 
| 59 | 
< | 
    Vector3d r43 = ghostAtom->getElectroFrame().getColumn(2); | 
| 59 | 
> | 
    Vector3d r43 = ghostAtom->getA().getColumn(2); | 
| 60 | 
  | 
     | 
| 61 | 
  | 
    //  Calculate the cross products and distances | 
| 62 | 
  | 
    Vector3d A = cross(r21, r32); | 
| 63 | 
  | 
    RealType rA = A.length(); | 
| 64 | 
  | 
    Vector3d B = cross(r32, r43); | 
| 65 | 
  | 
    RealType rB = B.length(); | 
| 66 | 
< | 
    Vector3d C = cross(r32, A); | 
| 67 | 
< | 
    RealType rC = C.length(); | 
| 66 | 
> | 
 | 
| 67 | 
> | 
    /*  | 
| 68 | 
> | 
       If either of the two cross product vectors is tiny, that means | 
| 69 | 
> | 
       the three atoms involved are colinear, and the torsion angle is | 
| 70 | 
> | 
       going to be undefined.  The easiest check for this problem is | 
| 71 | 
> | 
       to use the product of the two lengths. | 
| 72 | 
> | 
    */ | 
| 73 | 
> | 
    if (rA * rB < OpenMD::epsilon) return; | 
| 74 | 
  | 
     | 
| 75 | 
  | 
    A.normalize(); | 
| 76 | 
  | 
    B.normalize(); | 
| 71 | 
– | 
    C.normalize(); | 
| 77 | 
  | 
     | 
| 78 | 
  | 
    //  Calculate the sin and cos | 
| 79 | 
  | 
    RealType cos_phi = dot(A, B) ; |