For a segment joining \(\displaystyle \mathrm{P}(x_{1},y_{1},z_{1})\) and \(\displaystyle \mathrm{Q}(x_{2},y_{2},z_{2})\), direction ratios are \(\displaystyle x_{2}-x_{1},\ y_{2}-y_{1},\ z_{2}-z_{1}\), and the direction cosines are these divided by \(\displaystyle \mathrm{PQ}=\sqrt{(x_{2}-x_{1})^{2}+(y_{2}-y_{1})^{2}+(z_{2}-z_{1})^{2}}\).
Let \(\displaystyle \mathrm{A}(3,5,-4)\), \(\displaystyle \mathrm{B}(-1,1,2)\), \(\displaystyle \mathrm{C}(-5,-5,-2)\). Take the sides in order \(\displaystyle \mathrm{AB}\), \(\displaystyle \mathrm{BC}\), \(\displaystyle \mathrm{CA}\); the traps here are the subtractions of negative coordinates, so each difference is written out.
Side AB. Direction ratios: \(\displaystyle -1-3,\ 1-5,\ 2-(-4)=-4,\ -4,\ 6\).
\[\mathrm{AB}=\sqrt{(-4)^{2}+(-4)^{2}+6^{2}}=\sqrt{16+16+36}=\sqrt{68}=2\sqrt{17}. \]
Direction cosines of \(\displaystyle \mathrm{AB}\):
\[\frac{-4}{2\sqrt{17}},\ \frac{-4}{2\sqrt{17}},\ \frac{6}{2\sqrt{17}} \;=\; -\frac{2}{\sqrt{17}},\ -\frac{2}{\sqrt{17}},\ \frac{3}{\sqrt{17}}. \]
Side BC. Direction ratios: \(\displaystyle -5-(-1),\ -5-1,\ -2-2=-4,\ -6,\ -4\).
\[\mathrm{BC}=\sqrt{(-4)^{2}+(-6)^{2}+(-4)^{2}}=\sqrt{16+36+16}=\sqrt{68}=2\sqrt{17}. \]
Direction cosines of \(\displaystyle \mathrm{BC}\):
\[\frac{-4}{2\sqrt{17}},\ \frac{-6}{2\sqrt{17}},\ \frac{-4}{2\sqrt{17}} \;=\; -\frac{2}{\sqrt{17}},\ -\frac{3}{\sqrt{17}},\ -\frac{2}{\sqrt{17}}. \]
Side CA. Direction ratios: \(\displaystyle 3-(-5),\ 5-(-5),\ -4-(-2)=8,\ 10,\ -2\).
\[\mathrm{CA}=\sqrt{8^{2}+10^{2}+(-2)^{2}}=\sqrt{64+100+4}=\sqrt{168}=2\sqrt{42}. \]
Direction cosines of \(\displaystyle \mathrm{CA}\):
\[\frac{8}{2\sqrt{42}},\ \frac{10}{2\sqrt{42}},\ \frac{-2}{2\sqrt{42}} \;=\; \frac{4}{\sqrt{42}},\ \frac{5}{\sqrt{42}},\ -\frac{1}{\sqrt{42}}. \]
Each triple satisfies \(\displaystyle l^{2}+m^{2}+n^{2}=1\); e.g. for \(\displaystyle \mathrm{CA}\), \(\displaystyle \frac{16+25+1}{42}=1\).
Direction cosines of the sides:
\[\mathrm{AB}:\ -\frac{2}{\sqrt{17}},\ -\frac{2}{\sqrt{17}},\ \frac{3}{\sqrt{17}};\qquad \mathrm{BC}:\ -\frac{2}{\sqrt{17}},\ -\frac{3}{\sqrt{17}},\ -\frac{2}{\sqrt{17}};\qquad \mathrm{CA}:\ \frac{4}{\sqrt{42}},\ \frac{5}{\sqrt{42}},\ -\frac{1}{\sqrt{42}}. \]
Taking the sides in the opposite sense reverses all the signs in a triple, which is equally acceptable.