I am (like a hundred other people, like a thousand other people) trying to make a space flight simulator. I'm not a student. (That said, I found Orbit – space flight sim. It’s excellent.* You should try it.)

I have an Orbit object but, I can’t find all the functions I need. All of you must have a library/class that can manage an orbit. I Googled and looked on Github. If not a whole class, I’m looking for a functions (formulas) to get vectors for a prograde, retrograde, normal, anti-normal directions in an orbit.

  • When you use the autopilot to roll from Prograde to Normal (+), for example, it only needs to roll on one axis (Y if Y is up from the planet) but, it starts to roll on other axis, too. So, I’m working on a better roll program. I tried rewriting lerp to make it roll on the axis with the longest roll first and the others as needed (there percentage of their roll was less than the inverse of time (1 – t)); I.e., rolling on only the Y axis from 0 to 90 degs, without changing the other angles (assuming that they were already in one autopilot mode). V1( 0, 0, 0).mult(rad) to V2( 0, 90, 0).mult(rad). But, I can’t find out how to get a retrograde vector from an orbit. Well, I can draw an oval representing my orbit, and I can take two locations a degree apart, get the difference, normalize it and, hopefully, it gives me a prograde vector, but I think there might be a better way.

I found orekit but can’t make heads or tails of it. It looks like a bunch of dat file but I don’t see any code.

Can someone offer me a class or point me to one? Can someone tell me how to calculate prograde, etc., from Vector r and Vector v?
Can someone rewrite lerp (or slerp) to make the biggest change first (and maybe skipping the other axis if they don’t need to be changed)? Oh and, the following is good but, doesn’t give me all I need. Get r (bold) and v (bold) from r and v. Say what!? I’m looking at that again.

  • 1
    $\begingroup$ This site is set up to answer one question per post. You've got a lot going on there. I'm not sure asking someone to write code for you is really in the wheelhouse either. I suggest you edit your post down to one question that can have a right or wrong answer. $\endgroup$ – Organic Marble Mar 3 at 5:24
  • $\begingroup$ ditto. For example, "Can someone tell me how to calculate prograde, etc., from vectors $\mathbf{r}$ and $\mathbf{v}$? could be a major component of a question, but you'd have to define what you mean by "how to calculate prograde" first. $\endgroup$ – uhoh Mar 3 at 5:50
  • $\begingroup$ I saw your question and answer here. Each SE site is different. Questions about orbital mechanics here should try to include a reference to the specific equations you are trying to implement, and hopefully a specific scenario. Try searching this site to see if you can find a similar question. You can use key words, or tags or both in your search. $\endgroup$ – uhoh Mar 3 at 6:19
  • $\begingroup$ I see what I was doing. I started with the 6 orbital elements which gave me the position of a planet as a function of time but didn't give me r and v. I have to start with r and v and then the rest is calculate-able. Yes, that was my question about a spaceship auto-leveling. I had r but not v. So, I'll rewrite my class. Someone can delete this question or I will. $\endgroup$ – Xorange Mar 3 at 17:58