Jump to content
  • Advertisement
Sign in to follow this  
Sync Views

2d vector (maths, not STL) problem

This topic is 3739 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Quote:
...you found that the dot product gives you the magnitude of the projection, so the magnitude of P = -vi <bullet> N1. To get P to point in the same direction as the normal, you must multiply the magnitude of P by the normal, so the vector P = (-vi <bullet> N1) * N1, as shown in ...
the i is just below and too the right, and the 1 is above and to the right, wasn't sure how to type them... P, v and N are vectors. Ok, i'm lost here because I don't see how this products a vector, since a dot product just returns a single number or what the * N' is meant to be....

Share this post


Link to post
Share on other sites
Advertisement
hi

a dot product can also be described as a projection of the one vector onto the other vector

does that help?

so if you know the one vector then if you have the dotproject then you have a scala value that tells you the length of that vector.

Peter

Share this post


Link to post
Share on other sites
I assume P is the vector in question.

From your quote, the magnitude of P is found as (-vi)(<bullet>)(N1). This magnitude is a scalar.

If N1 is a vector (the normal vector), then you're multiplying the magnitude (scalar) of P by the vector N1, resulting in a vector.

vector * scalar = vector, scalar * scalar = scalar.

**another way to look at it:

You've found the length (magnitude) of P, now you're just taking that length and pointing it in the same direction as the normal vector N1.

Share this post


Link to post
Share on other sites
You are correct, the dot product will give you a scalar (single value) but multiplying that scalar against the normal (your confusion with * N') will scale that normal vector and produce another vector.

To scale a vector you will just multiply each component by the scalar. IE if your dot product results in some scalar S, and your vector is N = <x, y> then S * N = <S*x, S*y>.

Share this post


Link to post
Share on other sites
Looking at the formulas in the OP, there is a mysterious negative sign that seems me not to match the explanations in the text. Next, P is used once as scalar and once as vector. Next, P isn't enforced to point into the direction of N, but another vector is computed with that property. Next, the formula does not "multiply the magnitude of P by the normal". Hmm, that text is a bit mysterious to me. I assume what is meant is the following:

Presumbly n is a unit vector, i.e. its length is 1. With the correspondence
v . n == |v| * |n| * cos( <v,n> )
and the aforementioned assumption that |n|==1, it follows that
v . n == |v| * cos( <v,n> )
This can be interpreted as the length of v along the direction of n.

Now, multiplying n with that length
( v . n ) * n =: p
elongates that vector to the said length, resulting in the vector looking for.


EDIT: Ups, there is already the one or other answer; I'm too late.

Share this post


Link to post
Share on other sites
OP: use the HTML <sup /> (superscript) tag to get 2x and suchlike. Use HTML <sub /> (subscript) to get v1 and such.

Also, as Peter notes, that is not a superscript 1 beside the N, but a "prime" ordinal, usually written with an apostrophe (').

Share this post


Link to post
Share on other sites
So would this be right?

//this is a vector2 member method, normal is also a vector2
Vector2 tmp(-x, -y);//invert
Vector2 projection = normal.scale(tmp.dot(normal))

Share this post


Link to post
Share on other sites
Quote:
Original post by Sync Views
So would this be right?
*** Source Snippet Removed ***

It matches the formula in the text snippet. You can also avoid to work with the explicit tmp variable if using

Vector2 projection = normal.scale(-vector.dot(normal))
assuming that "vector" is the name of the variable storing v (i.e. whereof x and y are the components).

[ -x -y ]T . n == ( -[ x y ]T ) . n == - ( [ x y ]T . n )

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!