Jump to content
  • Advertisement
Sign in to follow this  
Ahl

Determining trajectory from X/Y movement.

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

Im trying to determine an objects angle of trajectory from its movment based on X/Y. To clerify im using: ship_X += cos(ship_angle * x_speed) ship_Y += sin(ship_angle * y_speed) Thats not the exact code but im sure you get my point. Im moving a ship around using the asteroids/newtonian physics. Now using that I want to be able to figure out the ships trajectory based on a 0-360deg rotation scale. How would I go about doing that? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
First off, speed is not a vector and should be put outside the trig functions
ship_X += cos(ship_angle)*speed
ship_Y += sin(ship_angle)*speed


Second, using vector components directly for your basic physics calculations will make your life alot easier. I'm also not sure what you mean by trajectory angle. What is it the angle between? The way the ship is facing and the velocity? The velocity and a point further in time taking the acceleration into consideration?

Quote:
Dictionary.com
Trajectory - the curve described by a projectile, rocket, or the like in its flight.


If you have a position, velocity,and acceleration vector at a point in time and you want to find the trajectory assuming acceleration is a constant you can use:
P(t) = P0 + V0*t + 0.5*A0*t*t
where t is the time from where P0,V0,A0 are measured.


I could probably be alot more helpful if you clarified the final goal.

Share this post


Link to post
Share on other sites
To clerify:

Ships movement will be handled like in asteroids. All newtonian physics. Point the ship in direction x and bump the thrusters and the ship will continue to move in that direction until I burn thrusters again in a different direction. What im looking for is a way to tell what direction the ship is moving becuase its not always going to be moving in the direction its facing.

Does that help?

Share this post


Link to post
Share on other sites
Quote:
Original post by Ahl
To clerify:

Ships movement will be handled like in asteroids. All newtonian physics. Point the ship in direction x and bump the thrusters and the ship will continue to move in that direction until I burn thrusters again in a different direction. What im looking for is a way to tell what direction the ship is moving becuase its not always going to be moving in the direction its facing.

Does that help?
That's still a bit confusing. The way that you 'tell what direction the ship is moving' is to maintain and update the velocity vector yourself (using simple Newtonian physics, as you note).

The velocity should be stored as a vector, not as an angle. The direction in which the ship is pointing can be stored as an angle if you wish, and converted to a vector when needed (e.g. when computing the thrust vector or the velocity of a projectile). The ship's angle of rotation will also of course be used when rendering the ship (assuming that it's not radially symmetrical).

If you're still stuck at this point, perhaps you could try stating your question in different terms.

Share this post


Link to post
Share on other sites
Ugh...

You know what? I think i've figured it out. I already have the code to determine an angle from 2 points. just generate a point using the ships present speed and angle and find the angle between that and ships location. I guess I just needed to think about it.

Thanks though.

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.

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

Sign me up!