This is what I was hoping you could help with, based on your research. If you found a good reference, I would be grateful if you could share it, since, as I said, your could seems better than what I have been able to find or derive on my own. I am not sure why you say you don't know what I mean about True Anomaly or Eccentric Anomaly, since you use those terms in your code.
Since I am not a rocket scientist nor a computer scientist, I doubt I can improve on it, which is why I asked the question.