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.