# Easy vector question...

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

## Recommended Posts

Sorry I'm not more descriptive in the subject, but I don't know what to name what I'm trying to accomplish (don't know much about the terminology of vector math). Here's what I'm trying to figure out...
A
.
.
.
*
-------*C
.
.
.
*
B

In the crudely drawn illustration, I have two 2-dimensional vectors, A and B. The head of each vector is the asterisk. Vector A is an object's old trajectory and vector B is that object's new trajectory. Vector C is a new vector based on vectors A and B, that points away from the point where the object's trajectory changed. Based on what you see here, how would I calculate Vector C? Thanks in advance for the help, I REALLY appreciate it! (EDIT) Edited picture, because backslashes weren't being drawn as Vector A's line. Changed line representations to 'dots' instead of 'slashes'.

##### Share on other sites
Google 'vector reflection' (or some variation thereof).

##### Share on other sites
suppose A and B are both normalized.
Let D = (A + B) / 2
Then C would be the vector normal to D
(-Dy, Dx)
or possibly
(Dy, -Dx)
(I don't want to think about which one would be correct :) Probably you'll have to consider both anyway).

##### Share on other sites
Thanks for the info, guys. And thanks for the formula, Koen! I'll give both your ideas a try and see which one works best.

Thanks again!

##### Share on other sites
Assuming A coming Towards C Moving VA velocity

you dont want B But rather VB

N = C.Normalized()

VB = VA - 2*dot(VA, N) * N

##### Share on other sites
wow raymond this took to 4 post to get right, everyone into graphics should know this formula by heart for shame lol

##### Share on other sites
Quote:
 wow raymond this took to 4 post to get right, everyone into graphics should know this formula by heart for shame lol

I think the problem description might be to blame here...

I still don't understand why, knowing the pre and post collision velocities you would want to know how to compute the normal of collision cf. "Based on what you see here, how would I calculate Vector C?".

As far as I can tell, the original question has not been completely answered yet. Yes, I'm picky ;).

##### Share on other sites
Quote:
 wow raymond this took to 4 post to get right, everyone into graphics should know this formula by heart for shame lol
Just because someone doesn't post an answer doesn't mean they don't know it :) Sometimes it's better (or easier, if you're feeling lazy) just to point someone in the right direction.

That said, as b34r noted the question wasn't actually what some of us thought it was. I think Koen already gave the answer, but just in case, I think you can find C as:

C = normalize(A-B)

You might give that a try and see if it's what you're looking for.

##### Share on other sites
You could also negate a and calculate c by:

c = -(a + b)

Just to skin the cat a little differently. :*)

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 14
• 30
• 9
• 16
• 22