Say x=(x1,x2). We can associate the angle θ to x where
cos(θ)=x1/x12+x22
sin(θ)=x2/x12+x22
Let a=(cos(α),sin(α)).
Let u be reference direction with ∥u∥=1.
Let β be an orthonormal basis with β1=u.
For any x we can write x=∑kαkβk.
Define πk(x)=αk where x has the above expression in the basis β.
Then π1(x)=α1=⟨x,u⟩
In 2 dimensions:
Suppose two vectors a,b are in R2.
We want to compute the cosine of the angle between them.
It should be independent of lengths so let u=a/∥a∥,v=b/∥b∥.
Suppose u=(cos(α),sin(α)),v=(cos(β),sin(β)).
By applying Rα−1 to v we get v1cos(α)+v2sin(α)=u1v1+u2v2 as first component. So u⋅v gives component of v in direction of u.
The expression is symmetric in u and v as desired. It also scales bilinearly with the norms of u and v.
In the end all we did was extend u to an orthonormal basis and find the component of v in the direction of u. Said component is independent of the particular orthonormal basis chosen so it is well-defined. In particular a Graham-Schmidt construction applied to {u,v} gives the usual formulae
u1w2u2=w1=u=v−⟨u,u⟩⟨u,v⟩u=v−⟨u,v⟩u=w2/∥w2∥
In general if we have a subspace W of an inner product space V, and the columns of the matrix AspanW then we can construct
the component xW of a vector x∈V which lies in W as: