Projection finds the part of one vector that points along another. The leftover part is perpendicular.
Write the projected vector as kv. Requiring u − kv to be perpendicular to v gives (u − kv)·v = 0, so k = (u·v)/(v·v).
Projection onto the zero vector is undefined.
Blue is u, green is v, and the red vector is the projection of u onto v.