It is simple mathematical geometrical relation as per which we know that if two lines are in opposite direction then the angle formed between them will 180. And if they are same direction the angle formed will be 0.

The same concept applies in case of force and displacement.