# Apparent Centering Problem When Using the Perifocal System to Draw Orbital Ellipses [closed]

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:

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!

QUESTION EDITS AND CLARIFICATIONS:

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.

• 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. – user24157 Aug 18 '20 at 19:33
• @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. – Keegan Aug 18 '20 at 19:56
• 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. – uhoh Aug 18 '20 at 23:11
• I’m voting to close this question because it was also cross-posted in Space SE where answers are currently accumulating. – uhoh Aug 18 '20 at 23:16
• 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. – Keegan Aug 18 '20 at 23:51

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:

• @uhoh it's not, I answered it in both places – Keegan Aug 19 '20 at 1:46
• 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! – uhoh Aug 19 '20 at 7:04
• 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. – uhoh Aug 20 '20 at 1:22