position function

({double rho, double theta}) position(
  1. double e,
  2. double a,
  3. double i,
  4. double omega,
  5. double w,
  6. double eAnom,
)

Apparent position angle and angular distance of binary components.

e eccentricity, a apparent semimajor axis (radians), i inclination, omega position angle of ascending node, w longitude of periastron, eAnom eccentric anomaly. All radians.

Implementation

({double theta, double rho}) position(
    double e, double a, double i, double omega, double w, double eAnom) {
  final r = a * (1 - e * math.cos(eAnom));
  final nu = 2 * math.atan(math.sqrt((1 + e) / (1 - e)) * math.tan(eAnom / 2));
  final sNuW = math.sin(nu + w);
  final cNuW = math.cos(nu + w);
  final ci = math.cos(i);
  final num = sNuW * ci;
  final theta = mod2pi(math.atan2(num, cNuW) + omega);
  final rho = r * math.sqrt(num * num + cNuW * cNuW);
  return (theta: theta, rho: rho);
}