export interface Fuel {
  main1: number;
  main3: number;
  main2: number;
  upperAux: number;
  lowerAux: number;
  main1Tip: number;
  main3Tip: number;
  tail: number;
  forwardAux1: number;
  forwardAux2: number;
}

// TODO: Extract from CFG at runtime.
export const EmptyArm = -159.6;

// TODO: Extract from CFG at runtime.
export const ArmsFuel = {
  main1: -240,
  main3: -240,
  main2: 120,
  upperAux: 0,
  lowerAux: 0,
  main1Tip: -468,
  main3Tip: -468,
  tail: -840,
  forwardAux1: 60,
  forwardAux2: 60,
};

// TODO: Extract following four from CFG at runtime
const rootChord = 34.68;
const wingSpan = 170.5;
const wingArea = 3648;
const quarterMAC = -165; //aero_center

const tipChord = (2 * wingArea) / wingSpan - rootChord;
const taperRatio = tipChord / rootChord;

const MAC = (2 / 3) * rootChord * ((1 + taperRatio + taperRatio ** 2) / (1 + taperRatio)) * 12;
const LEMAC = quarterMAC + (1 / 4) * MAC;

export const toPercentMAC = (positionInInches: number) => {
  return Math.abs(((positionInInches - LEMAC) / MAC) * 100);
};
