Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Jason2Jason

Total Forward Speed.

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

Hi. In my game i need to work out the total velocity in one diretion. This isn''t the usual question of ''how do i move forward in the direction i''m facing'' but more of ''how do i get the total forward speed from 2 velocities?'' I have a 2D Vector (well its not a vector, it represents velocity) called TmpVel (with 2 components x and y) In my movement function this is modified to apply Forward and Reverse forces. Then to get the real position of the object it does this:
Velocity.x = TmpVel.x * cos(Rotation*3.1415926/180);
Velocity.y = TmpVel.y * sin(Rotation*3.1415926/180);
 
My question is how would i get the current total forward (or backward) or speed from those x and y values? Is it as simple as adding the two components together? I''m just checking this to make sure i do it right. I''ve been doing alot of searching over the gamedev forums and found many extreamly useful topics about this moving forward issue. Just not this. Thanks -J

Share this post


Link to post
Share on other sites
Advertisement
What Waverider said. It seems to me that all you want is the scalar speed value of the vector, and in general, the magnitude of a vector is given by

Sqrt(x_1^2 + x_2^2 + ... + x_n^2)

for any vector with n elements.

Proving this in the 2-dimensional case is very easy. Just use Pythagoras

Share this post


Link to post
Share on other sites
yeah, the reason you couldn''t find information on it is because it is a simple mathematical concept. Obviously you haven''t covered Pythagorean Theorem yet. =)

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!