Public Group

# 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.

## Recommended Posts

Quote:
 ...you found that the dot product gives you the magnitude of the projection, so the magnitude of P = -vi 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 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 on other sites
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 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 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 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 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 on other sites
So would this be right?
//this is a vector2 member method, normal is also a vector2Vector2 tmp(-x, -y);//invertVector2 projection = normal.scale(tmp.dot(normal))

##### Share on other sites
Quote:
 Original post by Sync ViewsSo 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 )

1. 1
2. 2
3. 3
4. 4
Rutin
13
5. 5

• 12
• 15
• 9
• 14
• 10
• ### Forum Statistics

• Total Topics
632655
• Total Posts
3007675
• ### Who's Online (See full list)

There are no registered users currently online

×