• Launch Day is nearly upon us! Head over to this thread and share your thoughts before, during, and after Crew Dragon finally lifts off.

Question About Spaceship in (X,Y) Grid

Status
Not open for further replies.
F

Fishlore

Guest
I'm writing a computer program. Let's say I have a two dimensional spaceship in a two dimensional (X,Y) grid. It is probably moving and a pilot is probably trying to control it.

Two questions... What spaceship variables do I need to keep track of in order to predict its future position? Using these variables, what equations do I need to solve to predict the spacecraft's position in 1/32 of a second in the future?

For question 1, I figure I'll need at least the following variables...

current (X,Y)
mass
velocity
angle of velocity
thrust
angle of thrust

anything else? maybe length of time thrusting?

For question 2, what equations do I plug those values into in order to get the new (X,Y), or the change in current (X,Y)?


Is there a place online to learn about this stuff? Can anyone here help me? Any help would be appreciated.

Thanks in advance.
 
M

MeteorWayne

Guest
Fishlore":16rxqfut said:
I'm writing a computer program. Let's say I have a two dimensional spaceship in a two dimensional (X,Y) grid. It is probably moving and a pilot is probably trying to control it.

Two questions... What spaceship variables do I need to keep track of in order to predict its future position? Using these variables, what equations do I need to solve to predict the spacecraft's position in 1/32 of a second in the future?

For question 1, I figure I'll need at least the following variables...

current (X,Y)
mass
velocity
angle of velocity
thrust
angle of thrust

.
I might suggest the most important of all....the gravitational field it's embedded in :)
 
M

Mee_n_Mac

Guest
The way this is usually done is to determine the "state" of the system at any one point in time and then set whatever forces will act over the next interval and compute the resulting change in "state". So what variables are needed to describe the "state" of your spacecraft ? You've got a good list to start but let me add to it.

You need present position and you might as well break it down into X, Y components
You need present velocity, also in it's X, Y components
You need present acceleration, also in it's X, Y components
You need mass, because it will be changing as you toss some overboard in the course of making thrust

Given the above you can compute what they will be 1/32 sec in the future (holding them all steady for that time increment) and then recalculate, then, what the new state is and what, if any, forces are acting on the spacecraft.

You get the acceleration (F=MA) by knowing the forces acting on the space craft (in X, Y components so you need the "angle of thrust") at any one time. How you want to plug in the durations for thrust and it's magnitude over time is up to you. Velocity and position then fall out from Newton's equations (I assume your rocket isn't going to be accelerating to anything approaching light speed). In a single dimension :

X[sub]n+1[/sub] = X[sub]n[/sub] + V[sub]x,n[/sub]*(t) + 0.5*A[sub]x,n[/sub]*(t[super]2[/super])

V[sub]x,n+1[/sub] = A[sub]x,n[/sub]*(t)

A[sub]n[/sub] = k1*T[sub]x,n[/sub]/M[sub]n[/sub] ; k1 is to convert whatever units of thrust (force) into what units of mass and velocity you're using, ie newtons from lbs and ft/sec

M[sub]n+1[/sub] = M[sub]n[/sub] - k2*T[sub]x,n[/sub]*(t)

with X, V, A, T, M and t being the position, velocity, acceleration, thrust, mass and time interval (1/32 sec).
n, n+1 denote the time ("now") and next time ("now" + t) at which they are computed.

See these (if you haven't) ...

http://en.wikipedia.org/wiki/Thrust
http://en.wikipedia.org/wiki/Reaction_engine

So if you express thrust as a force, you'll need to know the exhaust velocity of the engine(s) you're modelling to back out the amount of mass tossed overboard each time interval.

Now I've assumed all the forces are acting through the center of mass and so no rotation results. If you want to be more real life you'll want to mimic all the above for rotation to determine the orientation (and spin rate and spin accel) of the spaceship vs time.

EDIT : I note that MW is correct and that if you want to include gravity then you'll need to add that force into the calcs for the acceleration at every instant. I'd guess you'd calculate the gravitational force based on some distance(s) from some body(ies) and so you'd need to calculate those geometries at each instant. Would those bodies be in motion relative to each other ? Gets to be fun, huh ? :cool:
 
M

MeteorWayne

Guest
I feel the need to point out that space is 3D, so really, you need X, Y, and Z :)
 
Status
Not open for further replies.

ASK THE COMMUNITY

TRENDING THREADS

Latest posts