The dihedral angle ($\phi$) is the angle between two planes.
First of all, we should know the General equation of Plane:
$\mathbf{Ax + By + Cz + D = 0}$ .......... (i)
Where $A, B, C, D$ are constants.
And, Equation of plane passing through points $(x_1, y_1, z_1), (x_2, y_2, z_2), (x_3, y_3, z_3)$ is,
$\begin{vmatrix}
x-x_1 & y-y_1 & z-z_1\\
x_2-x_1 & y_2-y_1 & z_2-z_1\\
x_3-x_1 & y_3-y_1 & z_3-z_1
\end{vmatrix}=0$ .......... (ii)
Or,
$\begin{vmatrix}
y_2-y_1 & z_2-z_1\\
y_3-y_1 & z_3-z_1
\end{vmatrix} (x-x_1) + \begin{vmatrix}
z_2-z_1 & x_2-x_1\\
z_3-z_1 & x_3-x_1
\end{vmatrix} (y-y_1) + \begin{vmatrix}
x_2-x_1 & y_2-y_1\\
x_3-x_1 & y_3-y_1
\end{vmatrix} (z-z_1) = 0$
.......... (iii)
After Solving $eq^n (iii)$, we get;
$\left.\begin{matrix}
\left \{ (y_2-y_1)(z_3-z_1) - (z_2-z_1)(y_3-y_1)\right \}x\;+\\
\left \{ (x_3-x_1)(z_2-z_1) - (x_2-x_1)(z_3-z_1)\right \}y\;+ \\
\left \{ (x_2-x_1)(y_3-y_1) - (x_3-x_1)(y_2-y_1)\right \}z + D = 0 \;\;\;\;\;\;\;\;\;\;\;
\end{matrix}\right\}$ .......... (iv)
Where $D$ is Constant term. This $eq^n (iv)$ gives the equation of plane passing through points.
Now,
From the above references, we have to calculate the Dihedral angle between the two planes:
$a_1x + b_1y + c_1z + d_1 = 0$ .......... (v)
$a_2x + b_2y + c_2z + d_2 = 0$ .......... (vi)
Which have normal vectors $n_1 = (a_1, b_1, c_1)$ and $n_2 = (a_2, b_2, c_2)$ is simply given dihedral angle through the dot product of the normals.
i.e. $Cos\phi = \hat{n_1}.\hat{n_2}$ .......... (vii)
Or,
$Cos\phi = \frac{a_1a_2 + b_1b_2 + c_1c_2}{\sqrt{a_1^2 + b_1^2 + c_1^2}\sqrt{a_2^2 + b_2^2 + c_2^2}}$ .......... (viii)
Note: Unit Vector - If A is a vector with magnitude A $\neq 0$), then $\hat{n} = \frac{\vec{A}}{\left | A \right |}$ is a unit vector having the same direction as $\vec{A}$.
Click here for: Basic concept on Dihederal angle.