# What is Vector Projection and what is it's use in games?

Couldn't find a clear enough answer on Google.

I know what vectors are. But what does it mean to project a vector onto another, and what is it used for in games?

Vector projection means finding the components of vector a that are in the same direction of vector b. Check my answer here for how to do it. Not only vector projection is important in game dev but vector decomposition in general, where you have a vector and you need to decompose it into 3(or 2) separate vectors in the u,v,w directions.

For example in order to find a local frame of reference (read: object space/coordinates) you often need to find three linearly independent vectors which form the frame of reference. You can start by finding the projection on X axis (or the local u direction) and then continue with cross product to find the third vector. The final step would to cross product the result two vectors from the previous operations.

Another situation in physics simulation you will often have force vectors that you need to find their sum in each direction, you cannot do that unless you do vector decomposition.

• Thanks for answering. What do you mean by 'finding the components of vector a that are in the same direction as vector b`? What 'components'? The 'direction' means the angle, right? Mar 26, 2014 at 13:44
• @Prog when you project a on b, the result vector say c , will have the same (x,y) components of b. That it will have the same direction as b but different length. Mar 26, 2014 at 13:53
• In the illustration, is the perpendicular line to b - vector c? If so, than as I said it is perpendicular to it, and not the same direction as b. What am I missing? Mar 26, 2014 at 18:56
• another question: By components do you mean the x and y values of the vector? If so, than each 2d vector has only two components by definition. However you said 'finding the components of vector a that are in the same direction as vector b'. I still don't get what you mean by that. vector a has two certain components, it's x and y values, and so does vector b. these components also define the direction. So how 'components of vector a' be the same 'direction' as 'components of vector b'? Sorry for taking long to understand. Mar 26, 2014 at 19:51