Project a onto nonzero b with proj_b(a) = (a·b / b·b)b. The dotted segment from a to its projection is perpendicular to b. The projection can point against b when the dot product is negative.
Project a onto nonzero b with proj_b(a) = (a·b / b·b)b. The dotted segment from a to its projection is perpendicular to b. The projection can point against b when the dot product is negative.