experience and innovation

---------------------------------------------------------------------------
   Cost function for the trimming algorithm
---------------------------------------------------------------------------
   Form:
   j = FTrim( v, x, d, g, w, nR )
---------------------------------------------------------------------------

   ------
   Inputs
   ------
   v                   Adjustable variables
   x             (:)   Aircraft state
                             r          (3,1) ECI position vector
                             q          (4,1) Quaternion from ECI to body
                             w          (3,1) Inertial body rate in body frame
                             v          (3,1) Velocity of cm wrt air
   d             (:)    Aircraft data structure
   g             (:)    Constraint structure
                          .vT    (1,1) Velocity             (required)
                          .rDot  (1,1) Climb rate           (optional)
                          .eDot  (3,1) Euler angle rate     (optional)
   w             (11,1)  Weights [vDot, wDot, rDot, eDot, engDot]
   nR             (1)   Number of rotors

   -------
   Outputs
   -------
   j                    Scalar cost

---------------------------------------------------------------------------