I understand the geometry and calculation of a dihedral angle. It is not clear how the direction is defined. On the wiki page for dihedral angles, it states that, "the dihedral angle \phi is the counterclockwise angle..." between the plane123 and the plane234 (where plane123 is defined as containing atom1, atom2, and atom3, etc.).
This counterclockwise definition means that the direction of the dihedral angle is defined using the left-hand rule which is extremely unusual. Alternatively, this example may be defining \phi to be the positive angle less than 180 degrees.
https://en.wikipedia.org/wiki/Dihedral_angle