Jump to content
  • Advertisement
Sign in to follow this  
Dookie

Easy vector question...

This topic is 4832 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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
You could also negate a and calculate c by:

c = -(a + b)

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

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!