Vector vs Scalar velocity?

Posted by Serguei Fedorov on Game Development See other posts from Game Development or by Serguei Fedorov
Published on 2012-12-09T07:38:15Z Indexed on 2012/12/09 11:22 UTC
Read the original article Hit count: 250

Filed under:
|

I am revamping an engine I have been working on and off on for the last few weeks to use a directional vector to dictate direction; this way I can dictate the displacement based on a direction. However, the issue I am trying to overcome is the following problem; the speed towards X and speed towards Y are unrelated to one another. If gravity pulls the object down by an increasing velocity my velocity towards the X should not change. This is very easy to implement if my speed is broken into a Vector datatype, Vector.X dictates one direction Vector.Y dictates the other (assuming we are not concerned about the Z axis). However, this defeats the purpose of the directional vector because:

  SpeedX = 10
  SpeedY = 15

  [1, 1] normalized = ~[0.7, 0.7]

  [0.7, 0.7] * [10, 15] = [7, 10.5]

As you can see my direction is now "scaled" to my speed which is no longer the direction that I want to be moving in.

I am very new to vector math and this is a learning project for me. I looked around a little bit on the internet but I still want to figure out things on my own (not just look at an example and copy off it). Is there way around this? Using a directional vector is extremely useful but I am a little bit stumped at this problem. I am sorry if my mathematical understanding maybe completely wrong.

© Game Development or respective owner

Related posts about XNA

Related posts about math