The triangle inequality, the law of cosines, cauchy inequality and variance of (X-Y).

The law of cosines c^2 = a^2 +b^2 - 2abCos(theta) looks a lot like the variance of (X-Y) where X and Y are random variables and cosine is replaced by covariance...but why?

What is the relationship between triangles and probability of two random variables? Something to do with orthogonal vectors forming the basis for a probability space I'm guessing, but that reaches the limit of what I know about linear algebra. Any insight is appreciated!

thanks much