Jump to content

Quick math question / Coding question?


Guest GroundHOG-2010

Recommended Posts

Guest GroundHOG-2010

Math question

If i was to burn upwards in space and get to a speed of 10 m.s upwards and then burn side ways and have sideways velocity of 10 m.s, how would I work out the vector of the two velocitys put together and the speed? And what would be the easiest way of calcualting this?

(I am coding a game which need this. Its 2d (as I can\'t do anything else as perfect as I want).

Forgot to mention: The problem with that is I am using 2 floats for direction, one float for the velocity direction and one for where the space ship is pointing at that very moment, so just adding vectors won\'t work

Link to comment
Share on other sites

Math question

If i was to burn upwards in space and get to a speed of 10 m.s upwards and then burn side ways and have sideways velocity of 10 m.s, how would I work out the vector of the two velocitys put together and the speed? And what would be the easiest way of calcualting this?

(I am coding a game which need this. Its 2d (as I can\'t do anything else as perfect as I want).

Pythagoras is your friend... ;)

http://en.wikipedia.org/wiki/Pythagorean_theorem

http://en.wikipedia.org/wiki/Vector_addition#Addition_and_subtraction

Link to comment
Share on other sites

You just add the vectors, the combined velocity is the magnitude of the resulting vector. In your example:

(10, 0) + (0, 10) = (10, 10)

the vector magnitude you can find out with Pythagoras\' theorem, which is:

v = sqrt(x^2 + y^2), or in the example ~= 14.14

Ninja\'ed, but here it is anyway

Link to comment
Share on other sites

Guest GroundHOG-2010

You just add the vectors, the combined velocity is the magnitude of the resulting vector. In your example:

(10, 0) + (0, 10) = (10, 10)

the vector magnitude you can find out with Pythagoras\' theorem, which is:

v = sqrt(x^2 + y^2), or in the example ~= 14.14

Ninja\'ed, but here it is anyway

The problem with that is I am using 2 floats for direction, one float for the velocity direction and one for where the space ship is pointing at that very moment... So it wouldn\'t work.

Link to comment
Share on other sites

The problem with that is I am using 2 floats for direction, one float for the velocity direction and one for where the space ship is pointing at that very moment... So it wouldn\'t work.

You should work either with Cartesian coordinates or Polar coordinates, looks like you are trying to work with both.

If you want the ship to move 'forward' accounting for her rotation, you will need to rotate the velocity vector you are adding.

Yes, things are starting to look ugly, welcome to game programming ;)

Link to comment
Share on other sites

Guest GroundHOG-2010

You should work either with Cartesian coordinates or Polar coordinates, looks like you are trying to work with both.

If you want the ship to move 'forward' accounting for her rotation, you will need to rotate the velocity vector you are adding.

Yes, things are starting to look ugly, welcome to game programming ;)

I have been programming for 2 years now. But I want to do proper physics for this... and this is what that involves.

crap I just realised that I can\'t use Pythagoras\' theorem because I am not using right angle triangles (or cartesian coordinates or polar coordinates). See you when I figure this out... in a month.

Link to comment
Share on other sites

Guest GroundHOG-2010

Pythagoras........ why do you follow me home now? I though I was done you when I got home from school......

Once again, its not using add the vectors or Pythagoras because they require right angle triangles, which is... not what I need. Thanks for trying though.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...