deflectLight function

Vector3 deflectLight(
  1. Vector3 u,
  2. Vector3 sunToBody,
  3. Vector3 sunToEarth
)

Deflection of light by the Sun (general relativity).

u – Earth→body direction (unit vector), sunToBody and sunToEarth – vectors from the Sun. Formula: Explanatory Supplement (2013), chapter 7.

Implementation

Vector3 deflectLight(Vector3 u, Vector3 sunToBody, Vector3 sunToEarth) {
  final q = sunToBody.unit, e = sunToEarth.unit;
  final g = 2 * solarGM / (speedOfLight * speedOfLight * sunToEarth.length);
  final shift = (e * u.dot(q) - q * e.dot(u)) * (g / (1 + q.dot(e)));
  return (u + shift).unit;
}