You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The use of arccos function to count angles from cartesian coordinates is not accurate when the angle is around 0 or 180 degrees. There the slope (derivative) of the cosine function is 0 so inverting it will be very inaccurate. We loose from the precision that we have in the cartesian coordinates. In the example code I would recommend to use atan2 everywhere it is possible. Besides the phase problem (which is rightly mentioned in the text several times) the accuracy is also a reason why using atan2 is the better choice to count the angle in almost all cases. We pass both the sine and the cosine value to the function and at least one of them will be at the part of the function which will yield high precision.
I would also like to send compliments. Your text on orbital mechanics really helps understanding and implementing the ideas necessary to simulate how the bodies move. It is by far the most complete and to the point document that I have found. Great work! I try to implement a KSP inspired game and this documentation is exactly what I need.
Thanks for reporting this! Feel free to update this section. I'd prefer to keep the arccos example for pedagogical purposes (and add a figure, but I don't expect you do to that 😉) , but adding a note and suggesting that atan2 is preferred from a practical standpoint would be very helpful!
The use of arccos function to count angles from cartesian coordinates is not accurate when the angle is around 0 or 180 degrees. There the slope (derivative) of the cosine function is 0 so inverting it will be very inaccurate. We loose from the precision that we have in the cartesian coordinates. In the example code I would recommend to use atan2 everywhere it is possible. Besides the phase problem (which is rightly mentioned in the text several times) the accuracy is also a reason why using atan2 is the better choice to count the angle in almost all cases. We pass both the sine and the cosine value to the function and at least one of them will be at the part of the function which will yield high precision.
I would also like to send compliments. Your text on orbital mechanics really helps understanding and implementing the ideas necessary to simulate how the bodies move. It is by far the most complete and to the point document that I have found. Great work! I try to implement a KSP inspired game and this documentation is exactly what I need.
An example of the usage of arccos is here:
orbital-mechanics-notes/classical-orbital-elements/orbital-elements-and-the-state-vector.md
Line 96 in 8d7bb83
The text was updated successfully, but these errors were encountered: