<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Aermacchi-MB-339    : BARANGER Emmanuel                 /2015
                 Updated : BARANGER Emmanuel               02/2021
                 Updated : BARANGER Emmanuel               10/2021
                 Updated : BARANGER Emmanuel/AMOROSO Paolo 03/2024

     Sources             : https://en.wikipedia.org/wiki/Aermacchi_MB-339

     Wingspan            : 10.86 m     ( 35 ft 7 1/2 in )
     Length              : 10.97 m     ( 36 ft 0     in )
     Height              :  3.60 m     ( 11 ft 9 3/4 in )
     Empty mass          :  3075 kg    ( 6780 lb        )
     Gross weight        :  4400 kg    ( 9700 lb        )
     Engine              : 1 Rolls-Royce Viper Mk. 632 turbojet, ( 4000 lbf )
     Maximum speed       :  898.0 km/h ( 485 kt ) at sea level
     Stall speed         :  148.5 km/h (  80 kt )

     Never exceed speed  : Mach 0.82   ( 926 km/h 500 kt )
-->
<airplane mass="6780" version="YASIM_VERSION_CURRENT" mtow-lbs="9700">

  <approach speed="115" aoa="2" fuel="0.3">
    <control-setting axis="/controls/engines/engine[0]/throttle" value="0.2"/>
    <control-setting axis="/controls/flight/flaps"               value="1"/>
    <control-setting axis="/controls/gear/gear-down"             value="1"/>
  </approach>

  <cruise speed="400" alt="19500" fuel="1.0">
    <control-setting axis="/controls/engines/engine[0]/throttle" value="1"/>
    <control-setting axis="/controls/flight/flaps"               value="0"/>
    <control-setting axis="/controls/gear/gear-down"             value="0"/>
  </cruise>

  <cockpit x="3.045" y="0" z="-0.140"/>

  <!-- Fuselage -->
  <fuselage ax=" 5.485" ay=" 0.000" az="-1.021" bx=" 4.286" by=" 0.000" bz="-0.841" width="0.706" taper="0.2" midpoint="1"/>
  <fuselage ax=" 4.350" ay=" 0.000" az="-0.841" bx=" 3.066" by=" 0.000" bz="-0.745" width="0.948" taper="0.7" midpoint="1"/>
  <fuselage ax=" 3.066" ay=" 0.000" az="-0.745" bx="-1.537" by=" 0.000" bz="-0.570" width="0.948" taper="1.0" midpoint="1"/>
  <fuselage ax="-1.537" ay=" 0.000" az="-0.570" bx="-5.201" by=" 0.000" bz="-0.458" width="0.948" taper="0.6" midpoint="0"/>

  <fuselage ax=" 4.361" ay=" 0.000" az="-0.773" bx=" 3.249" by=" 0.000" bz="-0.293" width="0.713" taper="0.6" midpoint="1"/>
  <fuselage ax=" 3.249" ay=" 0.000" az="-0.294" bx=" 2.089" by=" 0.000" bz="-0.040" width="0.713" taper="1.0" midpoint="1"/>
  <fuselage ax=" 2.193" ay=" 0.000" az="-0.069" bx=" 1.006" by=" 0.000" bz="-0.020" width="0.713" taper="1.0" midpoint="1"/>
  <fuselage ax=" 1.029" ay=" 0.000" az="-0.024" bx="-0.158" by=" 0.000" bz="-0.005" width="0.713" taper="0.4" midpoint="0"/>
  <fuselage ax="-0.158" ay=" 0.000" az="-0.005" bx="-4.361" by=" 0.000" bz="-0.007" width="0.285" taper="0.4" midpoint="0"/>

  <wing x="0.111" y="0" z="-0.846"
        chord="2.350"
        length="5.194"
        taper="0.6"
        sweep="6"
        dihedral="2"
        camber="0.005">
        <stall     aoa="20"  width="1"     peak="1.5"/>
        <flap0   start="0.10"  end="0.63"  lift="1.3" drag="1.5"/>
        <flap1   start="0.63"  end="0.93"  lift="1.3" drag="1.8"/>
        <spoiler start="0.374" end="0.613" lift="1"   drag="20"/>

        <control-input  control="SPOILER" axis="/controls/flight/spoilers"/>
        <control-input  control="FLAP0"   axis="/controls/flight/flaps"/>
        <control-input  control="FLAP1"   axis="/controls/flight/aileron"                  split="true" square="true"/>
        <control-input  control="FLAP1"   axis="/controls/flight/aileron-trim"             split="true"/>

        <control-output control="SPOILER" prop="/surface-positions/speedbrake-pos-norm"/>
        <control-output control="FLAP0"   prop="/surface-positions/left-flap-pos-norm"     side="left"/>
        <control-output control="FLAP0"   prop="/surface-positions/right-flap-pos-norm"    side="right"/>
        <control-output control="FLAP0"   prop="/surface-positions/flap-pos-norm"/>
        <control-output control="FLAP1"   prop="/surface-positions/left-aileron-pos-norm"  side="left" />
        <control-output control="FLAP1"   prop="/surface-positions/right-aileron-pos-norm" side="right"/>
        <control-output control="FLAP1"   prop="/surface-positions/aileron-pos-norm"/>

        <control-speed control="FLAP0"    transition-time="3"/>
        <control-speed control="SPOILER"  transition-time="3"/>
  </wing>

  <hstab x="-4.467" y="0" z="-0.266"
         chord="1.312"
         length="1.970"
         taper="0.6"
         sweep="7">
         <stall   aoa="18" width="1" peak="1.5"/>
         <flap0 start="0.18" end="1" lift="1.4" drag="1.1"/>

         <control-input  control="FLAP0" axis="/controls/flight/elevator" square="false"/>
         <control-input  control="FLAP0" axis="/controls/flight/elevator-trim"/>

         <control-output control="FLAP0" prop="/surface-positions/elevator-pos-norm"/>
  </hstab>

  <vstab x="-3.346" y="0" z="-0.428"
        chord="2.164"
        length="2.4"
        taper="0.5"
        sweep="25">
        <stall   aoa="16" width="1" peak="1.5"/>
        <flap0 start="0"    end="1" lift="1.2" drag="1.1"/>

        <control-input  control="FLAP0" axis="/controls/flight/rudder"      invert="true"/>
        <control-input  control="FLAP0" axis="/controls/flight/rudder-trim" invert="true"/>

        <control-output control="FLAP0" prop="/surface-positions/rudder-pos-norm"/>
  </vstab>

  <!-- Engines   source            : https://en.wikipedia.org/wiki/Armstrong_Siddeley_Viper

                 name              : Armstrong Siddeley Viper
                 type              : Turbojet
                 power             : 2700 lb at 13800 rpm
                 weight            : 549 lb (249 kg)
  -->
  <jet x="-0.015" y="0" z="-0.60"
       mass="549"
       thrust="4000"
       n1-idle="30"
       n1-max="90"
       n2-idle="35"
       n2-max="95"
       egt="850"
       tsfc="1.39">
       <actionpt x="-5.121" y="0" z="-0.546"/>
       <control-input control="THROTTLE" axis="/controls/engines/engine[0]/throttle"/>
  </jet>

  <!-- nose -->
  <gear x="4.307" y="0" z="-1.802"
        compression="0.2"
        spring="1.1"
        damp="1.4">
        <control-input  control="STEER"  axis="/controls/flight/rudder" src0="-1.0" src1="1.0" dst0="-0.8" dst1="0.8"/>
        <control-input  control="EXTEND" axis="/controls/gear/gear-down"/>

        <control-output control="EXTEND" prop="/gear/gear[0]/position-norm"/>

        <control-speed  control="EXTEND" transition-time="5"/>
  </gear>

  <!-- left main -->
  <gear x="-0.118" y="1.231" z="-1.664"
        compression="0.2"
        spring="0.85"
        damp="2">
        <control-input  control="BRAKE"  axis="/controls/gear/brake-left"/>
        <control-input  control="BRAKE"  axis="/controls/gear/brake-parking"/>
        <control-input  control="EXTEND" axis="/controls/gear/gear-down"/>

        <control-output control="EXTEND" prop="/gear/gear[1]/position-norm"/>

        <control-speed  control="EXTEND" transition-time="5.2"/>
  </gear>

  <!-- right main -->
  <gear x="-0.118" y="-1.231" z="-1.664"
        compression="0.2"
        spring="0.85"
        damp="2">
        <control-input  control="BRAKE"  axis="/controls/gear/brake-right"/>
        <control-input  control="BRAKE"  axis="/controls/gear/brake-parking"/>
        <control-input  control="EXTEND" axis="/controls/gear/gear-down"/>

        <control-output control="EXTEND" prop="/gear/gear[2]/position-norm"/>

        <control-speed  control="EXTEND" transition-time="5.4"/>
  </gear>

  <!-- tanks                (0) -->
  <tank x="0.415" y=" 0.000" z="-0.665" jet="true" capacity="1250"/>

  <!-- Tip wings tanks      (1 2) -->
  <tank x="0.256" y=" 5.207" z="-0.659" jet="true" capacity="335"/>
  <tank x="0.256" y="-5.207" z="-0.659" jet="true" capacity="335"/>

  <!-- Wings tanks          (3 4) -->
  <tank x="0.556" y=" 2.777" z="-1.205" jet="true" capacity="335"/>
  <tank x="0.556" y="-2.777" z="-1.205" jet="true" capacity="335"/>

  <!-- Tip wings tanks      (0 1) -->
  <weight x="0.256" y=" 5.207" z="-0.659" mass-prop="sim/weight[0]/weight-lb"/>
  <weight x="0.256" y="-5.207" z="-0.659" mass-prop="sim/weight[1]/weight-lb"/>

  <!-- Wings tanks          (2 3) -->
  <weight x="0.556" y=" 2.777" z="-1.205" mass-prop="sim/weight[4]/weight-lb"/>
  <weight x="0.556" y="-2.777" z="-1.205" mass-prop="sim/weight[5]/weight-lb"/>

  <!-- AIM-9M               (4 5) -->
  <weight x="0.395" y=" 3.596" z="-1.180" mass-prop="sim/weight[2]/weight-lb"/>
  <weight x="0.395" y="-3.596" z="-1.180" mass-prop="sim/weight[3]/weight-lb"/>

  <!-- Smoke tanks or MK 82 (6 7) -->
  <weight x="0.212" y=" 4.303" z="-0.977" mass-prop="sim/weight[6]/weight-lb"/>
  <weight x="0.212" y="-4.303" z="-0.977" mass-prop="sim/weight[7]/weight-lb"/>

  <!-- Mass distribution
       Dilbert : The cg should be about 1/6 chord ahead of the chord center.
                 2.350 / 6     = 0.391
                 0.111 + 0.391 = 0.502
  -->
  <ballast x="5" y="0" z="-1" mass="1448"/>

</airplane>
