This came up in a practical problem (physics).

In the following, we work with real numbers only, and consider every vector to be normalized to 1.

To find how "similar" two vectors are (actually, two lines passing through the origin, I don't care about the direction), one can use the scalar product. If the two lines are the same, then the scalar product of the corresponding vectors is 1 or -1. If they are "similar", it's close to 1. If they're perpendicular, it's 0.

I need a generalization of this "similarity measure" to $k$-dimensional subspaces.

For example, for $k=2$ I have the following problem: I have vectors $a_1 \perp a_2$ which define a plane in an $n$-dimensional space, and vectors $b_1 \perp b_2$. I need a measure that 1. tells me how close these planes are to each other, in terms of $a_1, a_2, b_1, b_2$. is a generalization of the simple scalar product (i.e. it's the same as the scalar product for $k=1$).