Skip to main content
gamedev.net
🔒 Locked

parametrized space launch

Started by flashingchicken 2 replies 1k views
Original Post
flashingchicken
flashingchicken
was wondering where i made my blunder, can't figure it out. once is airborn, and there is 0 thrust, there is no deceleration.

#define THRUST 2090000//kN
#define DRYMASS 80000 //kg
#define INITFUEL  0 //kg
#define RADIUSEARTH 6378.1  //km
#define GMEARTH 	3986005//x10^8 	m3/s
class Spaceship{
//theta = angle from verticle to axis of ship
//phi = angle frme verticle to angle of V
//gamma = angle from top of world to space ship
public:
double theta, phi, gamma; 
long double height;
double mass, drag,velocity; 
float thrust_percent;
Spaceship()
{ theta=0; phi=0; gamma=0; height=0;
mass=0; drag=0;velocity=0; thrust_percent=0;
 }
 };
 
 void Update_Spaceship(Spaceship *player, int delta_t)
 {    long double Vx, Vy, V, T, Fg;  //m/s x3 N
      float dt=(float)delta_t/1000.;
      V=player->velocity;
      T=THRUST*(player->thrust_percent*10.)/player->mass;
      Fg=GMEARTH/pow(player->height,2);
      Fg=Fg*100000000;
      Vx=V*sin(player->phi) + T*dt*sin(player->theta);
      Vy=V*cos(player->phi)+(T*cos(player->theta) - Fg)*dt;
      V=sqrt( pow(Vx,2)+pow(Vy,2));
      player->velocity=V;
      player->phi=atan2(Vx,Vy);
      player->height+=(Vy*dt);
      player->gamma+=atan2(Vx*dt,player->height);}
someusername
someusername
Quote:

once is airborn, and there is 0 thrust, there is no deceleration.

Have you implemented some form of air drag or friction or some "braking" force to cause deceleration?
An object will maintain its motion until acted upon by an external force.
In the absence of forces, the spaceship will continue to move, with constant velocity and no acceleration/deceleration "ad infinitum".

flashingchicken
flashingchicken
in this line
Vy=V*cos(player->phi)+(T*cos(player->theta) - Fg)*dt;

it *should* be the sum of the current velocity in the y, plus the thrust in the y minus the force of gravity
flashingchicken
flashingchicken
wow, i feel like a big dum dum, but, got the problem fixed, was using km instead of m, so, was getting far enough out quickly enough to almost negate gravity.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.