code: public static final double torsionAngle(Atom a, Atom b, Atom c, Atom d) {
  
  		Atom ab = subtract(a,b);
  		Atom cb = subtract(c,b);
  		Atom bc = subtract(b,c);
  		Atom dc = subtract(d,c);
  
  		Atom abc = vectorProduct(ab,cb);
  		Atom bcd = vectorProduct(bc,dc);
  
  		double angl = angle(abc,bcd) ;
  
  		/* calc the sign: */
  		Atom vecprod = vectorProduct(abc,bcd);
  		double val = scalarProduct(cb,vecprod);
  		if (val < 0.0)
  			angl = -angl;
  
  		return angl;
  	}
docs: Calculate the torsion angle, i.e. the angle between the normal vectors of
  the two plains a-b-c and b-c-d. See
  http://en.wikipedia.org/wiki/Dihedral_angle
  
  @param a
  an Atom object
  @param b
  an Atom object
  @param c
  an Atom object
  @param d
  an Atom object
  @return the torsion angle in degrees, in range +-[0,180]. If either first
  3 or last 3 atoms are colinear then torsion angle is not defined
  and NaN is returned