Determining trajectory from X/Y movement.

This topic is 4163 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 on other sites
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.comTrajectory - 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 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 on other sites
Quote:
 Original post by AhlTo 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 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.

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 9
• 12
• 16
• 26
• 10
• Forum Statistics

• Total Topics
633769
• Total Posts
3013759
×