I am attempting to render orbital ellipses in software. Given a set of orbital elements, I am using the Perifocal system to determine a set of points along the curve of the ellipse. I am using the equation:

r = r cos(v) P + r sin(v) Q,

where v is the angle, P and Q are the perifocal vectors correspondent to I and J, and r is the polar equation of the conic:

r = p / 1 + e cos(v),

where p is the semi-latus rectum, e is eccentricity, and v, in both equations, is the angle.

I am determining the vectors P and Q using the following equations:

Pi =   cos (lan) cos (aop) - sin (lan) cos (inc) sin (aop)
Pj =   sin (lan) cos (aop) + cos (lan) cos (inc) sin (aop)
Pk =   sin (inc) cos (aop)

Qi = - cos (lan) sin (aop) - sin (lan) cos (inc) cos (aop)
Qj = - sin (lan) sin (aop) + cos (lan) cos (inc) cos (aop)
Qk =   sin (inc) cos (aop)

where lan is the Longitude of Ascending Node, aop is the Argument of Periapsis, and inc is the inclination.

This process yields the correct ellipse! However, the ellipse does not seem to be centered correctly on its focus; the focus appears to be far too close to the center of the ellipse. Here is an example:

enter image description here

You can see that these two highly eccentric ellipses have their shared center of mass at their centers - not at their respective foci.

Is there some step in my process that I'm missing? I could just apply an offset to the ellipses, but that would be a hack, I want to solve the problem.

Any help is appreciated! Thank you!


This image is taken from a vantage point nearly normal to the orbital plane; there is almost no perspective here.

Second, a helpful user has pointed out an issue in the equation for Pk. The correct expression is:

Pk = sin (inc) sin (aop)

Unfortunately, this was correct in my code - so while the correction was a good one, it was not the source of my problems.

  • 1
    $\begingroup$ Have you tried rendering the orbits face-on? It's easier to see if you've got the focus in the right position when they aren't rendered at an oblique angle. $\endgroup$
    – user24157
    Aug 18, 2020 at 19:33
  • $\begingroup$ @antispinwards - yes! I can actually maneuver the camera wherever I need it. The provided view is nearly dead-on. You can actually see a really faint coordinate grid to get your bearings. We are probably like 15-20 degrees off the plane's normal. However, these two ellipses should be in a drastically different formation. Even from this slightly ambiguous perspective they're definitely way off. They should have significant overlap. $\endgroup$
    – Keegan
    Aug 18, 2020 at 19:56
  • 1
    $\begingroup$ This was cross-posted in Space SE You didn't know this but cross-posting the same question in multiple SE sites is strongly discouraged because it can lead to answer fragmentation; a future reader may find one copy of the question and the information there (comments, answers) and not find the other copy with more important information. You can no longer delete the copy in Space SE because there is now an answer posted, so let's close this one in such a way that people finding it will be guided to the other copy where answers are accumulating. $\endgroup$
    – uhoh
    Aug 18, 2020 at 23:11
  • 5
    $\begingroup$ I’m voting to close this question because it was also cross-posted in Space SE where answers are currently accumulating. $\endgroup$
    – uhoh
    Aug 18, 2020 at 23:16
  • 1
    $\begingroup$ Hey guys, I didn't realize that crossposting wasn't allowed - my apologies. It turns out unfortunately that the math based answer in space SE, was not the source of my issues. $\endgroup$
    – Keegan
    Aug 18, 2020 at 23:51

1 Answer 1


I solved the issue.

Everything I posted in the OP was correct; I made a simple, stupid sign error when transcribing the expressions into code.

It should also be noted that in the OP, the expression for Pk is wrong. The correct expression is

Pk = sin (inc) sin (aop)

Just in case anybody is trying to pull this off themselves!

Thanks for the ideas everyone!

Correct Orbits:

enter image description here

  • 1
    $\begingroup$ @uhoh it's not, I answered it in both places $\endgroup$
    – Keegan
    Aug 19, 2020 at 1:46
  • $\begingroup$ Oh I thought I'd deleted that about five minutes after I posted it after I re-read this, sorry about that, and well done! $\endgroup$
    – uhoh
    Aug 19, 2020 at 7:04
  • $\begingroup$ by the way it's also okay to accept one's own answer if one feels it's correct, as it seems it is in this case. $\endgroup$
    – uhoh
    Aug 20, 2020 at 1:22

Not the answer you're looking for? Browse other questions tagged .