wasn't 100% sure which StackExchange to ask this on, as it could be related to Gamedev (as it's for a game), maths (as it's a approximation model rather than a physical description) or StackOverflow (as I'm implementing it in a programming language, lua to be specific), so sorry if this is the incorrect place.
So a short description, I'm working on a game with a patched conic approximation of orbits ala Kerbal Space Program.
I've got a simple keplerian orbital simulation going on, calculating the orbital elements from my position and velocity vectors and drawing my orbit by calculating radius as a function of true anomaly (side question: is there a better way to do this? I've noticed this method leads to distortion in some orbits, usually elliptical ones with a very high eccentricity)
So, I really have two questions, which are fairly closely related.
Is there a deterministic, preferably without iteration, method of calculating when and where an orbit will go above or below a certain altitude? I'm doing this currently using binary intersection using the apsis' as starting values. I'm sure there's a better and more accurate way, and importantly faster way. The value I'm using to determine the "position" along the orbit is the true anomaly, if there's a better variable to use I'd like to know that too!
Is there a way to determine the true anomaly (or superior equivalent) when it intercepts a target with a known sphere of influence? The target and orbit will always be around the same body (And the SoI of the currently orbited object will always be "higher" than the maximum sphere of influence at the Apoapsis of the intercepted object) and the target will never leave the currently orbited objects sphere of influence either.
Thanks for any help you can offer and if I've been ambiguous or anything needs elaboration please ask!