vector projection

Started by
2 comments, last by boomji 19 years, 4 months ago
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
remember what you see to see what you rememberb
Advertisement
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).
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)
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honor to meet you and you may call me V.".....V



hey thanks so much guys...it's sinking in slowly but surely.
thanks again.


b
remember what you see to see what you rememberb

This topic is closed to new replies.

Advertisement