Sign in to follow this  
boomji

vector projection

Recommended Posts

hi, the formula goes something like this. (u.v)/v * v/|| v || . could someone break this down for me. is vector projection used to find out primarily how much a given vector is pointing in the direction of another vector. what does (u.v)/v give me a magnitude ??? by which i'm scaling it with a normal direction vector v/|| v || . i'm almost there to understanding it intutively just need a litte clarification and simplifying. could someone derive this equation. thanks a lot. b

Share this post


Link to post
Share on other sites
I've never seen that equation specifically, usually i've always projected one vector onto another (in essense finding the component of the first vector that lies along the second vector, as you have guess) by using a simple dot product. Perhaps your equation is derived from that?

If you want to project vector vA onto vB,

you first turn vB into a unit vector. This means you are looking for the vectors DIRECTION, not its length (length will be set to 1).

So take vB.x / vB.length;
vB.y / vB.length;
vB.z / vB.length;

if you do it right, SQRT(vB.x^2 + vB.y^2 + vB.z^2) should == 1.
that will give you a new vector, call it vB.unit or something.

then you do vA * vB.unit; Where * is the dot product.
Now, the dot product returns a float, not a vector. (an interesting side effect of this float is that if you do cos(the number you get) you find the angle between the two vectors) So this may be a problem depending on what value you need. If you just want to know numerically how similar the vectors are, the decimal number is fine. However you will usually want the actual vector component of vA that is on top of vB.
So just take that decimal you get from the dot product, and multiply it by a direction. (The unit vector of vB, is in this case, the direction you want).

Share this post


Link to post
Share on other sites
Quote:
Original post by boomji
(u.v)/v * v/|| v ||

The equation is actually (u.v)/||v|| * v/||v||

I think CombatWombat did a good job of explaining it, but just to add you can also rearrange that to get some speed. If you multiply the denominators together you get the length squared, which avoids the sqrt(). This gives (u.v)/(||v||^2) * v. Alternatively you can make this a little more readable by writing the length squared as the the dot product of v with itself, giving v*(u.v)/(v.v)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this