I have an object that is orbit around a point mass in a 2D environment with a known speed, radius and zenith. I calculate the following orbital parameters as such and can confirm that these values are correct (where $R_{p}$ is the periapsis, $R_{a}$ is the apoapsis, $e$ is the eccentricity, $a$ is the semimajor axis, $r$ is the radius, $v$ is the velocity and $GM$ is the product of the mass of the point mass and the gravitational constant):
$C = \frac{2GM}{rv^{2}}$
$R_{p} = r \times \frac{-C+\sqrt{C^{2}-4(1-C)(-\sin^{2}(1-C))}}{2(1-C)}$
$R_{a} = r \times \frac{-C-\sqrt{C^{2}-4(1-C)(-\sin^{2}(1-C))}}{2(1-C)}$
$e = \left | \frac{R_{a} - R_{p}}{R_{a} + R_{p}} \right |$
$a = \frac{R_{a} + R_{p}}{2}$
I then go on to attempt to calculate the true anomaly of the orbit as follows (where $z$ is the zenith and $\theta$ is the true anomaly):
$N = \frac{rv^{2}}{GM}$
$\theta = \tan^{-1} \frac{N\sin z \cos z}{(N\sin^{2} z)-1}$
This is calculates a correct value as long as the radius is greater than a value slightly less than the semiminor axis of the orbit. Adding pi to the true anomaly corrects this error, except where the radius is close in value to the length of the semiminor axis.
Why is the true anomaly off by ~pi in this case?
sin(a)**b
. You've not made this explicit and you're not really consistent with parentheses. Does this evaluate as(sin(a))**b
orsin(a**b)
? $\endgroup$(sin(a))**b
. $\endgroup$