CostSail2D:

--------------------------------------------------------------------------
   Cost function for 2D solar sail trajectory optimization.
   It computes an err magnitude
   that the optimizer uses to find the minimum.
   This function is for the planar orbit problem which includes
   radial position, radial velocity, tangential velocity and mass.

   Since version 7.
--------------------------------------------------------------------------
   Form:
   [errMag, err, x, t] = CostSail2D( lambda, d )
--------------------------------------------------------------------------

   ------
   Inputs
   ------
   lambda         (3,1)  Costates [r;dr/dt;drtheta/dt]
   d              (1,1)  Structure
                         .rhsFun      (1,:)  Associated RHS function for optimizer
                         .plotFun     (1,:)  Associated plot function for optimizer
                         .accel       (1,1)  Sail acceleration
                         .mu          (1,1)  Gravitational parameter
                         .x0          (3,1)  Initial state from optimizer
                         .xF          (3,1)  Final state from optimizer
                         .tEnd        (1,1)  Final time from opimizer
                         .oDEOptions  (1,:)  ode113 options
                         .errorScale  (3,1)  Weights for the error

   -------
   Outputs
   -------
   errMag         (1,:)  Magnitude of the error
   err            (3,1)  Error vector
   x              (:,n)  [states;costates]
   t              (1,n)  Time

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

Children:

Common: Database/Constant
Math: Linear/DupVect
Math: Linear/Mag
SC: Ephem/Planets