Quote from
wiki: This formula can be generalized to orthogonal projections on a subspace of arbitrary dimension. Let $u_1, \dots, u_k$ be an orthonormal basis of the subspace U, and let A denote the n-by-k matrix whose columns are u1, ..., uk. Then the projection is given by $P_A = A A^\top$.