Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actual___

Posted 23 May 2013 - 01:55 PM

So i have a jet.

I make a force that moves it. but when i set it to 0 (this force) the jet stops, but it shouldn't, it should at least move with this force(because i didn't include drag force )

 

but i have no idea how to implement intertia there.

 

lets assume i got drag force (lets call it drag_force)

all forces are vectors with length of acting force and its direction in my case ;]

if this helps you here is the code

 



void __fastcall TVehicle::ProcessFrame()
{



Gather_All_INFO();

AIRLIERON_LEFT->Frame_tick();
AIRLIERON_RIGHT->Frame_tick();
ELEVATOR_LEFT->Frame_tick();
ELEVATOR_RIGHT->Frame_tick();
RUDDER_LEFT->Frame_tick();
RUDDER_RIGHT->Frame_tick();

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    double l;
			timin->stopTimer();

l = timin->getElapsedTime();

float dt = float(l);
timin->startTimer();


if (dt <=0 ) return;


float Front_force = Throttle_to_force( Throttle );   //thrust force val

float Q = eGForce * mass;    // gravity force val


  ThrustForce_vec  = YPRangle.rf;                 //thrust force direction

  pos_from_plane_to_planet_center = vectorAB(pos, zero);

  GForce_vec  = Normalize( pos_from_plane_to_planet_center ); //g force direction




GForce_vec 		= vector_multiple(GForce_vec, Q);
ThrustForce_vec = vector_multiple(ThrustForce_vec, Front_force);

result_force = vectors_add(GForce_vec, ThrustForce_vec);//add forces

		   //divide vector by float
Acceleration = result_force / mass;      // a = F / m

dk = ( dt*dt );

accvel = Normalize( Acceleration );

Translation = vector_multiple(Acceleration, dk);
Translation = vector_multiple(Translation, 0.50f); //(a * t^2 )/ 2
s = V * dt;
accvel = vector_multiple(accvel, s);         //  V0 * t   => convert it to vector
	 Translation = vectors_add(Translation, accvel);   //add vectors v0t + (at^2)/2   => s= v0t + at^2 / 2
		   t3dpoint rp = vectors_add(pos, Translation );      //move to new position
		   if ( rp.y < 0 ) rp.y = 0.0f;
			pos = rp;
                                                      // v = s / t
	  V = n3ddistance(pos,old) / dt;  // s = V * t 						v=s/t

											old = pos;  //save position

}

as you can see i use result_force

this need to be changed to intertia but how? ;x

 

like always i attach a video

 

by the way i have problems with calculation velocity properly but as soon i will deal with this problem and add some things i will make a new post ;P


#1___

Posted 23 May 2013 - 01:43 PM

So i have a jet.

I make a force that moves it. but when i set it to 0 (this force) the jet stops, but it shouldn't, it should at least move with this force(because i didn't include drag force )

 

but i have no idea how to implement intertia there.

 

lets assume i got drag force (lets call it drag_force)

all forces are vectors with length of acting force and its direction in my case ;]

if this helps you here is the code

 

void __fastcall TVehicle::ProcessFrame()
{



Gather_All_INFO();

AIRLIERON_LEFT->Frame_tick();
AIRLIERON_RIGHT->Frame_tick();
ELEVATOR_LEFT->Frame_tick();
ELEVATOR_RIGHT->Frame_tick();
RUDDER_LEFT->Frame_tick();
RUDDER_RIGHT->Frame_tick();

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    double l;
			timin->stopTimer();

l = timin->getElapsedTime();

float dt = float(l);
timin->startTimer();


if (dt <=0 ) return;


float Front_force = Throttle_to_force( Throttle );   //thrust force val

float Q = eGForce * mass;    // gravity force val


  ThrustForce_vec  = YPRangle.rf;                 //thrust force direction

  pos_from_plane_to_planet_center = vectorAB(pos, zero);

  GForce_vec  = Normalize( pos_from_plane_to_planet_center ); //g force direction




GForce_vec 		= vector_multiple(GForce_vec, Q);
ThrustForce_vec = vector_multiple(ThrustForce_vec, Front_force);

result_force = vectors_add(GForce_vec, ThrustForce_vec);//add forces

		   //divide vector by float
Acceleration = result_force / mass;      // a = F / m

dk = ( dt*dt );

accvel = Normalize( Acceleration );

Translation = vector_multiple(Acceleration, dk);
Translation = vector_multiple(Translation, 0.50f); //(a * t^2 )/ 2
s = V * dt;
accvel = vector_multiple(accvel, s);         //  V0 * t   => convert it to vector
	 Translation = vectors_add(Translation, accvel);   //add vectors v0t + (at^2)/2   => s= v0t + at^2 / 2
		   t3dpoint rp = vectors_add(pos, Translation );      //move to new position
		   if ( rp.y < 0 ) rp.y = 0.0f;
			pos = rp;
                                                      // v = s / t
	  V = n3ddistance(pos,old) / dt;  // s = V * t 						v=s/t

											old = pos;  //save position

}

as you can see i use result_force

this need to be changed to intertia but how? ;x


PARTNERS