Julio or anyone. Forces and Torque help?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Julio or anyone. Forces and Torque help?

Postby Gibbon » Mon Mar 07, 2011 5:18 am

Hi, i have asked this before and unfortunatly im a still having problems understanding it so just wondering if anyone could try and explain it in a way i could understand it. :)

Im trying to impliment some aerodynamics into my flight simulator but i always seem to come back to the same problem of turning a body?

Even if its a plane or just a single body, i always have the same problem.

The current way i "turn" an object is by applying a torque to it, which i know is the wrong way about doing it. So what is the correct way?

If i have a plane moving forward with its force behind it , i want to turn it and have it move in its new direction.

The way i do it now cause the body to "slide" along for a while before it eventually starts to move in the new direction, like a car drifting alot, i dont want this.

I have drawn a diagram to help show what im trying to do.

Andy
prob.png
prob.png (35.38 KiB) Viewed 5800 times


Hope you can help.
Thanks
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Julio or anyone. Forces and Torque help?

Postby Julio Jerez » Mon Mar 07, 2011 9:10 am

the simplest way you can do control is by building and force component model.
basically you set your plane and all of the airfoils in an array, then in a loop you start by setting the force vector to the airplane weight, and the torque to zero
then for each air foil you accumulate the force and torque generated by that airfoil,
then you add that final force and torque to the rigid body, and that should do it.
the loop should look like this
Code: Select all
void applyAiplaneForce(body)
{
    vector force = mass * gravity
   vector torque = 0

   for each airfold on eh plane
  {
      vector airfoilForce;
      vector airfoilTorque;
     CalculateAirfoilForceAndToque (Airfoil[i], airfoilForce, airfoilTorque)
    force += airfoilForce
    torque += airfoilTorque
  } 
  NewtonBodySetForce (body, force)
  NewtonBodySetTouqre (body, torque)
}
 
// this funtion in only concerned with teh caculation of the aerodynamic force generated on and air foil 
void  CalculateAirfoilForceAndToque (Airfoil[i], airfoilForce, airfoilTorque)
{
     // calculate the airforce lift
    vector liftforce = AirforlLift ....

     // calculate the airforce drag
    vector dragtforce = AirforlDRag ....

    // total airfoild
   airfoilForce  = liftforce + dragtforce

   // total airforltoque, in general AirfoilLocalOrigin is located at the aerodynamics center of the wing
   airfoilOriginInGlobalSpace  = AiplaneMatrix.Rotate (AirfoilLocalOrigin)
    airfoilTorque = crossProduct (airfoilOriginInGlobalSpace ,   airfoilForce);
}


after you code that then your control the plane by adding and turning the wing, for example a typical plane can have: right wing, left wing, rear left aileron, rear right aileron, rooter.
you can even consider the plane body to be a aerodynamics body too, the engine does not change only the parameters of each wing, or aerodynamics body.
if you do it like that you can reproduce quite easily all of the behavior of all airplane in existence, Jets, light aircraft, gliders, anything even a flight brick.

your image will reflect a more accurate model if you drew a force on the right at the center of the right airfoil,
and a force on the left at the center of the left wing, then you will see that the turning torque will come naturally as an emergent physics behavior when the two force have different magnitude

for example say you want to emulate the turn of a Jet fighter.
Jet fighter need to Bank in order to produce tight turns, the way they do that is for example say they want to turn to the right
They decrease the lift on the right and increase the lift on the left wing by the same amount until the plane bank by same amount,
then they level the lift, now the plane is flighting straight with but with a tilt angle,
now if you increase the front lift and decrease the rear lift, the plane will try to go up in each step for as long the front and rear lift are misbalanced.
That is how high speed airplane turn.

Flying wing like the B2 require different maneuver because the do no have rooter or aileron so they exhibit the same behavior you show in the picture.
they require very, very long distance to turn, or the order of hundred on miles, basically flight wing are bodies that can only flight straight.
It is only with a computer program that the long sequence of moves required to make a flight wing to turn that a pilot can control it.
but for any normal airplane with front, rear, left and right airfoil, the sequence of step are simple.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Julio or anyone. Forces and Torque help?

Postby Gibbon » Mon Mar 07, 2011 3:34 pm

Hi julie, thank you for help, i am now trying to implement this into my simulator.

One thing i do not udnerstand is this:

airfoilOriginInGlobalSpace = AiplaneMatrix.Rotate (AirfoilLocalOrigin)

Your say "airfoilOriginInGlobalSpace" but then you request the "AirfoilLocalOrigin"??

Could you explain this please?

Thank you
Andy
Last edited by Gibbon on Mon Mar 07, 2011 4:02 pm, edited 2 times in total.
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Julio or anyone. Forces and Torque help?

Postby Julio Jerez » Mon Mar 07, 2011 3:52 pm

you save each airfoir as a point relative to the center of the airplane.
then to rotate the center of the wing from loacal to global space all you need to do is Rotate that local vector by the tranformtaion matrix of the body.
Basically it is the equivalent to doing a wing tunnel simulation when each wing is at the center of the world and all forces are espressed in the global space of the tunnel.
for example say you are calculation the right wing. from the point of view of a person in the airplane the center of the right wing will by a vector of the form (x0, y0, z0)
where z0 will be a positive value measure for the plane origin, x0 anx y0 are the wing cordenates relative to the plane origin.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Julio or anyone. Forces and Torque help?

Postby Gibbon » Mon Mar 07, 2011 4:03 pm

Ok ill look into this now:

Also I dont understand why you calculate lift as vectors?

// calculate the airforce lift
vector liftforce = AirforlLift ....

// calculate the airforce drag
vector dragtforce = AirforlDRag ....

my calculation for lift is: "airfoil_lift = 0.5 * CL * r * (velocityl.z * velocityl.z) * wa" this is not a vector??

Thanks
Andy
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Julio or anyone. Forces and Torque help?

Postby Gibbon » Mon Mar 07, 2011 4:48 pm

ahh why does it appear to be so difficult?

I have tried and tried and tried and no matter what i do i can not get even the SIMPLIST of flight movements?

To be exactly honest, im trying to replicate the flight movement and controls of a paraglider (parachute style)

So there is only ONE airfoil, but this could be split into 2 for left and right and the weight is very low benith the wing.

How hard can it be to get the BASIC flight movements, because it appears impossible to me.

Is there any code examples of a VERY basic flight movement?

Thanks
Andy
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Julio or anyone. Forces and Torque help?

Postby Julio Jerez » Mon Mar 07, 2011 5:59 pm

It is not hard at all, in fact it is quite trivial. Your problem is that that you do not have strong base on vector algebra so that you can understand the have the mathematic of flight works.

Any way here is a simple explanation of what the equation of lift means.

Whaty thes expesiion
"airfoil_lift = 0.5 * CL * r * (velocityl.z * velocityl.z) * wa"
means isL:

The magnitude of the lift force is proportional to the air speed, (i believe the correct formulate says the square, but you wrote a linear) time the coefficient of lift of the airfoil time the angle of attack.

The expresion does not say the direction of the Lift force, but I will tell you that.
The direction of the lift force is perpendicular to the AirSpeed, on the plane formed but the AirSpeed and the Angle of attack. (look it up in your book or on the internet)

To translate that definition to a C function you just have to calculate each term individually.
Here is a function to do that.

Code: Select all
vector CalulateAirforlForce (vector windVelocity, float coeficientOfLift)
{

   Matrix planeMatrix (NewtonBodyGetMatrix);

   // calculate the air speed,
   // this is the difference between the plane velocity and the wind velocity
   vector planeVelocity (NetwopngetVelocity(body));
   vector airSpeed (planeVelocity - windVelocity);

   // calculate the angle of Attack, this angle is the cross product projects over the side vector of the plane matryx
   // airSpeedVector = (unitAirSpeed x planeMatrix.front) % planeMatrix.right;
   vector unitAirSpeed (airSpeed.Normalize());
   vector angleOfAttackVector (crossProduct (unitAirSpeed, planeMatrix.m_front));
   float angleOfAttack (asin (dotproduct (planeMatrix.m_front, angleOfAttackVector)));

   // check if the angle of attack in largest that the stall angle
   if (angleOfAttack > MaxAngleOfAttack) {
      angleOfAttack = 0.0f;
   }

      
   // calculate the direction of the Lift Force
   // this is a vector perpendicular to the AirSpeed in the plane of the angle of attack
   vector lifgForceDir (CrossProduct (angleOfAttackVector, unitAirSpeed);
   lifgForceDir = lifgForceDir.Normalize();


   // now calculate the manitud of lift force
   float liftMag = DotProduct (airSpeed, airSpeed) * coeficientOfLift * angleOfAttack;

   // now return the lift force vector
   return lifgForceDir.AScale (lifgForceDir);
}


The function for Drag force si almost idential epcent that teh diretion of teh Drag Force, is teh negative of the normalized airSpeed

The way to controll the plane is by changing the coeficenet of Lift of the wind.
when the aileron moves up of down, what is does is that it chnege the corvature of eth wing,
move aileron down makes the upper side of teh wing more round and increases the coeficent of liff

so wha to do is teh you map you imput to the coeficent of lifg of each wing

for example
C = Cwing + Cimput * imputValue

vector CalculateAirforlForce (windVelocity, C);

so to go up all you do is to pull you joitic back, and all airfril move dwon.
to turn right pull joistic to teh left and the righ aileron gor up while the left fors down
these umbalace the force on teh left and right and teh plane bank,
at the same tiem the tail wind bot go up to decreas the lift and the plane turns.

the wing speed you can set to zero, but sicn ethso is a gloder you set it tio teh air speed on teh poin teh plane si at.
you can do coll thing like turbulence, which is nithing but the wing speed on the right side being different to the air speed on the left at random form frame to frame.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Julio or anyone. Forces and Torque help?

Postby Gibbon » Mon Mar 07, 2011 6:41 pm

Thanks Julio, You are correct my vector algebra is not very good, but i am trying my hardest to understand it, i really want to!

Could you tell me as i am using lua, what is % used for? and also "x"?

And also, in the above code, you calculate:

// now calculate the manitud of lift force
float liftMag = DotProduct (airSpeed, airSpeed) * coeficientOfLift * angleOfAttack;

But you do not use it anywhere??

Thank you
Andy
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Julio or anyone. Forces and Torque help?

Postby Julio Jerez » Mon Mar 07, 2011 7:21 pm

Oh my mistake, this the correct
return lifgForceDir.Scale (lifgForceMag);

% in the Math libarru si dot product
* in the cross product you cna also write as x
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Julio or anyone. Forces and Torque help?

Postby Gibbon » Mon Mar 07, 2011 7:42 pm

ok thank you julio.

Oh also, what is ".scale"? What does this function do. I know what .normalise does, but unsure about .scale?

Thank you
Andy
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Julio or anyone. Forces and Torque help?

Postby Julio Jerez » Mon Mar 07, 2011 7:48 pm

.scale multiply a vector by a float.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Julio or anyone. Forces and Torque help?

Postby Gibbon » Tue Mar 08, 2011 5:38 am

ahh i see, ok iam starting to understand it alot more now.

Whilst looking through the code i have just a few more questions.

Am i correct in saying you calculate the forces of the wings, but apply all the force and torque to the fuselarge?

Also, where would i caluclate velocity and its vector into this?

and you wrote:
// calculate the air speed,
// this is the difference between the plane velocity and the wind velocity
vector planeVelocity (NetwopngetVelocity(body));
vector airSpeed (planeVelocity - windVelocity);

Do you mean WING velocity, or WIND velcoity?

Thank you again for having patients with me. :)

Andy
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Julio or anyone. Forces and Torque help?

Postby Julio Jerez » Tue Mar 08, 2011 8:52 am

The velocity is the current velocity that teh body has, you ready form teh newton body or from your data struture that represent teh phisics.
I mean Wind velocody, (the velocity of the air) for a simpel test you can asuume to be zero.
yes all forces are applied to the Airplane frame.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Julio or anyone. Forces and Torque help?

Postby Gibbon » Wed Mar 09, 2011 7:16 pm

I think the only thing i can do..is give up.

I have tried to impliment what you have done above using leadwerks and NGD and it just does not work.

I never thought it would be this difficult to get even the VERY BASIC flight movements, that arnt even that realistic, i cant even get BASIC movements.

If only there was working example code of such BASIC movement.

Andy
Gibbon
 
Posts: 44
Joined: Tue Dec 15, 2009 5:18 am

Re: Julio or anyone. Forces and Torque help?

Postby Julio Jerez » Wed Mar 09, 2011 8:38 pm

Well I am sorry I can not help you.
The math is actually quite eassy but of you do not have the traing and the expereince working with vector algebra and apply mathematics it will be difficult for you.
Maybe Leadwerk can give you some pointers.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests