Kepler’s Ellipses

Jed Rembold

January 21, 2026

Announcements

  • Homework 1 due Friday night
    • Check that you can export standalone HTML documents before late on Friday!
    • I’ll probably be around until the basketball games on Friday (and don’t have a gigantic meeting) if you have last minute questions
  • I still need about 10 of you to fill out the info and reflection form here

A Note on Packages

  • Given that all of you generally fall into 1 of 2 camps (R or Python), where possible I’m going to try to not rely on package specific implementations
  • That said, there are some common ones that will repeatedly come up:
    • Python
      • Pandas introduces dataframes, which makes ideas much more similar to R’s dataframes
      • Matplotlib is still the workhorse of data visualization in Python
      • Numpy will probably make occasional appearances for pure number crunching
    • R
      • Tidyverse brings so many nice quality of life improvements and added functionality
      • ggplot is one of the best data visualization libraries I’ve seen
  • Specific applied libraries may also spring up, but as much as possible I’ll try to give both camps equivalent options

Today’s Plan

  • Angular Differences and Distances
  • What can we determine with positions?
    • Kepler’s 1st Law
  • Ellipse Math
  • Ellipse Fitting

Differences and Distances

Angular Separation

  • Frequently it is useful to describe the angular separation, or distance, between two points (as seen from Earth)
    • Pythagorean theorem will be close for small separations, but not quite accurate. Better to use: \[ \theta \approx \sqrt{\left(\left(\alpha_A - \alpha_B\right)\cos\delta_A\right)^2 + \left(\delta_A - \delta_B\right)^2} \] where \(\alpha\) indicates Right Ascension and \(\delta\) the Declination

Venus: 23h16m59.9s -3°57'57.3"Saturn: 23h11m37.9s -7°17'33.9"

Relating to Physical Distance

distance separation

  • If you know both things to be approximately the same distance away, you can convert angular separation to a physical distance: \[ \frac{\theta}{360^\circ} = \frac{\text{separation}}{2\pi(\text{distance})} \]
    • \(\text{distance}\) is the distance from the observer to the object in question,
    • \(\theta\) is the angular separation (in degrees)
    • \(\text{separation}\) is the physical separation
  • The physical separation will have the same units as the distance you use

Orbits

Tycho Brahe

  • Last real “naked-eye” astronomer
  • Took very precise angle measurements of stars and planets
  • Did not believe in a heliocentric universe, as he saw no stellar parallax
  • Hired Johannes Kepler to analyze all his data
Brahe’s observations

Johannes Kepler

  • Kepler then spent 8 years trying to reconcile Tycho’s observations of Mars with the Ptolemaic (Earth centered) model

Who would have thought it possible? This hypothesis, which so closely agrees with the observed oppositions, is nevertheless false? If I had believed that we could ignore those 8 minutes, I would have patched up my hypothesis accordingly. But since it was not possible to ignore them, those 8 minutes point the road to a complete reform of astronomy…

Thou seest now, diligent reader, that the hypothesis based on this method not only satisfies the four positions on which it was based, but also correctly represents within 2 minutes all the other observations.

Nova Astronomica – Johannes Kepler

Kepler’s 1st Law

  • The orbits of the planets are ellipses
  • The Sun sits at one focus, with nothing at the other

Ellipse Math

An Ellipses Aside

  • Look like squished circles

  • Described by:

    • Major Axis (longest width)
      • Half lengths are “semi-”
    • Minor Axis (shortest width)
    • Foci distances
    • Eccentricity (squished-ness)

Some Ellipse Math

You can always get the foci locations and eccentricity from the semi-major and minor axes.

  • Foci: \[ f = \sqrt{a^2 - b^2} \]
  • Eccentricity: \[ \varepsilon = \sqrt{1 - \frac{b^2}{a^2}} \]
  • Area: \[ A = \pi a b \]

Elliptical Orbits

  • Most planets in the Solar System have orbits that are not very eccentric

  • The Sun is clearly not at the center however

Projections

  • When observing, you rarely get a perfectly top-down view of an ellipse
  • Often, you are looking at some view projected from the side
    • This does not change the measurement of the period (how long it takes to complete one revolution)!
    • It may make measuring the semi-major axis more difficult though
  • Since many planets (and moons) have mostly circular orbits, you can estimate the major axis by just taking the largest end-to-end distance that you observe

More Vocab

  • Apogee/Aphelion: The point at which a body is at its furthest from the Earth/Sun
  • Perigee/Perihelion: The point at which a body is at its closest to the Earth/Sun

Ellipse Fitting

Pesky Ellipses

  • Because the elliptical orbits that space objects follow are tied directly to some physical properties, it can be very useful to determine elliptical parameters
  • The classic equation of an ellipse: \[ \frac{(x-x_c)^2}{a^2} + \frac{(y-y_c)^2}{b^2} = 1 \] allows for no rotations
  • The general polynomial form: \[ Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0 \] doesn’t give obvious expressions for the desired parameters

Fitting Tactics

  • There are a variety of approaches, most perform best when the sampled points come from around the entire ellipse
    • Different approaches can error in different ways if all points are from one side of the ellipse
  • All the pre-built options required some odd libraries and worked in very different ways between Python and R
  • So I found starting code for both and then customized to create fitting options that work very similarly in both

Library Explanation

  • Both libraries introduce 3 main functions. To get access to them, ensure that the fitellipse.* file is in the same directory as your notebook or source file, and then run or import the library
    • In Python:

      run fitellipse.py

      or

      from fitellipse import *
    • In R:

      source('fitellipse.r')

Library Functions

  • The 3 main functions are:
    • fit_ellipse(x, y): Computes the best fit ellipse and returns both the coefficients and the common fit parameters as an associative array. Takes points to fit as lists of x and y coordinates.
    • get_ellipse(fit_params): Computes a series of x and y points representing the given ellipse, where fit_params is the output of fit_ellipse. Useful for visualization purposes.
    • create_test_ellipse(Rx,Ry,Cx,Cy,Rotation,NoiseLevel): creates a series of x and y coordinates representing an ellipse with the given parameters

Caveats

  • Both fitting functions seem to do excellent at determining the center of the ellipse and major and minor axes
  • There is some variability with the resulting angle, where it sometimes comes out \(90^\circ\) off (\(\pi/2\) technically since the angle is in radians)
    • I believe this stems from discrepancies with whether it ends up finding the angle from the major or minor axis, but I’ve spent hours trying to make it more robust and thus far failed
    • Fortunately, the angle of the ellipse has absolutely no bearing on any physical laws, and is only of interest for visualization purposes
      • If the angle of the ellipse is wrong when plotting, add or subtract \(\pi/2\) from it

Example with Comet NeoWISE

  • Comet NeoWISE made an appearance several years back
    • That particular comet had a huge eccentricity and thus couldn’t easily be visualized
  • A different NeoWISE comet though has its positions over the next 100 years stored here
  • How could I estimate the eccentricity of this comet?

Return of Kepler

Kepler’s 2nd Law

  • A line joining a planet to the Sun sweeps out equal areas in equal times
    • Results in planets moving faster when close to the Sun and slower when far away

Kepler’s 3rd Law

  • The square of a planet’s orbital period is proportional to the cube of its semi-major axis.
    • A planet’s period is the time it takes to complete an entire orbit
    • An orbit’s semi-major axis we defined earlier to be half the major axis
  • Mathematically, this looks like: \[ p^2 \propto a^3 \qquad\text{or}\qquad \frac{p^2}{a^3} = \text{constant} \] where \(p\) is the period and \(a\) is the semi-major axis
  • For objects orbiting the Sun, if you choose units of years and AU, then \[ p^2 \approx a^3 \]
    • 1 AU = 1 astronomic unit = average distance from Earth to Sun (\(1.496\times10^{11}\) meter)
// reveal.js plugins // Added plugins ,