nasa / jeod

Other
26 stars 5 forks source link

Apparent inconsistency between documentation and code in calculating third body effect using Battin's method #7

Open DavidHammen opened 8 months ago

DavidHammen commented 8 months ago

Line 361 of models/environment/gravity/src/gravity_controls.cc reads

double q = (Vector3::vmagsq(integ_pos) + 2.0 * r_dot_rho) / rho_sq;

This appears to be inconsistent with the gravity model documentation (models/environment/gravity/docs/gravity.pdf), wherein equation 3.18 says $$q = \frac{\vec r\cdot(\vec r - 2\vec \rho)}{\rho^2}$$ Note the plus sign in line 361 versus the minus sign in the documentation. This turns out to be not a bug. The documentation uses $\vec \rho, \vec r, \text{and}\ \vec d$ to be consistent with Battin while the code uses grav_source_frame.pos in lieu of $\vec \rho$. The two vectors grav_source_frame.pos and $\vec \rho$ are additive inverses, thereby making the code consistent with the documentation. A comment to that effect would be useful.