## LPEccentric:

```--------------------------------------------------------------------------
Computes the thrust trajectory to go from an initial state x0
to a final state xF in the Hill's frame. Simplex is used to optimize the thrust.
Algorithm works for an eccentric reference orbit. It does not however account for
disturbances. In case eccentricity = 0, the solution obtained is the
same as that obtained for a circular reference frame using LPCircular.

A control system can be expressed in its discrete state-space form as:
X(k+1)      = A(k)X(k) + B(k)U(k)
Y(k)        = C(k)X(k)
where X is state , U is control, Y is output
For the nth timestep, this can be rewritten as:
X(n)        = A(n-1)*A(n-2)...A(n-n)*X(0) + [A(n-1)*A(n-2)...A(n-(n-1))*B   A(n-1)*A(n-2)...A(n-(n-2))*B ..... B]u
where u     = [ U(0)' U(1)' ..... U(n-1)']'
For a fully controllable and observable system,
Y(n) = X(n) = A(n-1)*A(n-2)...A(n-n)*X(0) + pu where p = [A(n-1)*A(n-2)...A(n-(n-1))*B   A(n-1)*A(n-2)...A(n-(n-2))*B ..... B]
error       >= |Y(n) - Y(desired)| = A(n-1)*A(n-2)...A(n-n)*X(0) + pu - Y(desired)

The Simplex problem (minimise cu(cost) such that au <= b) and u >= 0 can now be posed as
[-p; p]u    <= [error + A(n-1)*A(n-2)...A(n-n)*X(0) - Y(desired); error - A(n-1)*A(n-2)...A(n-n)*X(0) + Y(desired)]
In case of an Equality Constraint with 0 error, this reduces to
[-p]u        =  A(n-1)*A(n-2)...A(n-n)*X(0) - Y(desired)
Note: The constraintType determines whether it is an equality
technological constraint( au = b, flag: 0) or an inequality technological
constraint( au <= b, flag: 1)

u are called 'decision variables', in this case thrust vector
Since u is unrestricted in sign (u can be positive and negative),
we split u into two parts: u=up-um, where up>=0 and um>=0.

Since version 7.
--------------------------------------------------------------------------
Form:
[aC,t,exitFlag] = LPEccentric( e, n, x0, xF, nu0, nuF, nS, cW, cType, maxC )
--------------------------------------------------------------------------

------
Inputs
------
e                 (1)  Orbit eccentricity
n                 (1)  Mean orbit rate (rad/sec)
x0               (6,1) Initial state in Hill's frame
xF               (6,1) Final state in Hill's frame
nu0               (1)  Initial true anomaly (rad)
nuF               (1)  Final true anomaly (rad)
nS                (1)  Number of samples to use for control vector
cW                (:)  Cost weighting vector (optional)
cType             (1)  Flag with value 0 or 1 (optional, default: 0)
0 : Equality Constraint on the Linear program formulation
1 : Inequality Constraint on the Linear program
formulation
maxC              (1)  Maximum constraint on u (optional, default: 1e25)

-------
Outputs
-------
aC               (3,nS)   Commanded acceleration in Hill's frame
t                (1,nS+1) Time vector (sec)
exitFlag          (1)     Feasible solution = 1, No feasible solution = 0
--------------------------------------------------------------------------
```

## Children:

```FormationFlying: EccDynamics/FFEccLinOrb
Math: Analysis/Simplex
Math: Linear/Mag
Math: Trigonometry/UnwrapPhase
SC: BasicOrbit/Nu2M
SC: BasicOrbit/OrbRate
```