ThrusterAlignment:

Path: FormationFlying/Coord

% Computes body vectors to align with velocity and nadir for a thruster firing.
   The constraint is to keep the star tracker pointed as far away from the sun,
   earth and moon as possible.

   Since version 7.
--------------------------------------------------------------------------
   Form:
   [uBVelocity, uBNadir, qEB] = ThrusterAlignment( r, v, aH, bHET, bST, jD, sep, constrain );
--------------------------------------------------------------------------

   ------
   Inputs
   ------
   r               (3,1)  Position in ECI at burn time  [km]
   v               (3,1)  Velocity in ECI at burn time  [km/s]
   aH              (3,1)  Unit Hills frame vector of applied acceleration
   bHET            (3,1)  Unit body vector of Hall Effect Thruster nozzle
   bST             (3,1)  Unit body vector of star tracker bore-sight
   jD               (1)   Julian Date of burn time      [JD]
   sep              (1)   Required angular separation between bore-sight and 
                           bright body horizon          [rad]
   constrain        (1)   Flag to indicate whether to consider bright-body constraint 
                          Optional. Default is 1 (constraint considered)

   -------
   Outputs
   -------
   uBVelocity      (3,1)  Unit body vector to align with velocity direction
   uBNadir         (3,1)  Unit body vector to align with nadir direction
   qEB             (4,1)  Desired ECI-to-body quaternion
   okay             (1)   Boolean flag indicating whether angular separation
                           constraints were satisfield
   
--------------------------------------------------------------------------