code: public double getTorsionAngle(Point3d a, Point3d b, Point3d c, Point3d d) {
          Vector3d ab = new Vector3d(a.x - b.x, a.y - b.y, a.z - b.z);
          Vector3d cb = new Vector3d(c.x - b.x, c.y - b.y, c.z - b.z);
          Vector3d dc = new Vector3d(d.x - c.x, d.y - c.y, d.z - c.z);
          Vector3d bc = new Vector3d(b.x - c.x, b.y - c.y, b.z - c.z);
          Vector3d n1 = new Vector3d();
          Vector3d n2 = new Vector3d();
  
          n1.cross(ab, cb);
          if (getSpatproduct(ab, cb, n1) > 0) {
              n1.cross(cb, ab);
          }
          n1.normalize();
          n2.cross(dc, bc);
          if (getSpatproduct(dc, bc, n2) < 0) {
              n2.cross(bc, dc);
          }
          n2.normalize();
          return n1.dot(n2);
      }
docs: Calculates the torsionAngle of a-b-c-d.
  
  @param  a  Point3d
  @param  b  Point3d
  @param  c  Point3d
  @param  d  Point3d
  @return    The torsionAngle value