Incircle and excircles

An earlier post looked at the nine-point circle of a triangle, a circle passing through nine special points associated with a triangle. Feuerbach’s theorem that says the nine point circle of a triangle is tangent to the incircle and three excircles of the same triangle.

The incircle of a triangle is the largest circle that can fit inside the triangle. When we add the incircle to the illustration from the post on the nine-point circle, it’s kinda hard to see the difference between the two circles. The nine-point circle is drawn in solid black and the incircle is drawn in dashed green.

If we extend the sides of the triangle, an excircle is a circle tangent to one side the original triangle and to the extensions of the other two sides.


The nine-point circle theorem

The nine-point circle theorem says that for any triangle, there is a circle passing through the following nine points:

  • The midpoints of each side.
  • The foot of the altitude to each side.
  • The midpoint between each vertex and the orthocenter.

The orthocenter is the place where the three altitudes intersect.

Illustration of Feuerbach's nine-point circle theorem

In the image above, the midpoints are red circles, the altitudes are blue lines, the feet are blue stars, and the midpoints between the vertices and the orthocenter are green squares.


Posts on ellipses and elliptic integrals

I wrote a lot of posts on ellipses and related topics over the last couple months. Here’s a recap of the posts, organized into categories.

Basic geometry

More advanced geometry


Straight on a map or straight on a globe?

Straight lines on a globe are not straight on a map, and straight lines on a map are not straight on a globe.

A straight line on a globe is an arc of a great circle, the shortest path between two points. When projected onto a map, a straight path looks curved. Here’s an image I made for a post back in August.

Quito to Nairobi to Jerusalem and back to Quito

The red lines form a spherical triangle with vertices at Quito, Nairobi, and Jerusalem. The leg from Quito to Nairobi is straight because it follows the equator. And the leg from Nairobi to Jerusalem is straight because it follows a meridian. But the leg from Quito to Jerusalem looks wrong.

If you were flying from Quito to Jerusalem and saw this flight plan, you might ask “Why aren’t we flying straight there, cutting across Africa rather than making a big arc around it? Are we trying to avoid flying over the Sahara?”

But the path from Quito to Jerusalem is straight, on a globe. It’s just not straight on the map. The map is not the territory.

Now let’s look at things from the opposite direction. What do straight lines on a map look like on a globe? By map I mean a Mercator projection. You could take a map and draw a straight line from Quito to Jerusalem, and it would cross every meridian at the same angle. A pilot could fly from Quito to Jerusalem along such a path without ever changing bearing. But the plane would have to turn continuously to stay on such a bearing, because this is not a straight line.

A straight line on a Mercator projection is a spiral on a globe, known as a loxodrome or a rhumb line. If a plane flew on a constant bearing from Quito but few over Jerusalem and kept going, it would spiral toward the North Pole. It would keep circling the earth, crossing the meridian through Jerusalem over and over, each time at a higher latitude. On a polar projection map, the plane’s course would be approximately a logarithmic spiral. The next post goes into this in more detail.

loxodrome spiral

I made the image above using the Mathematica code found here.

Although straight lines the globe are surprising on a map, straight lines on a map are even more surprising on a globe.

Related posts

Random illustrations of Pascal’s theorem

Pascal’s theorem begins by selecting any six distinct points on an ellipse and drawing a “hexagon.” I put hexagon in quotes because the result need not look anything like a hex nut. In this context it simply means to pick one point, connect it to some other point, and so forth, joining the points in a cycle. The points need not be in order around the ellipse, and so the hexagon can, and usually will, be irregularly shaped.

Pascal’s theorem says that the intersections of opposite sides intersect in three points that lie in on a common line. Since the hexagon can be irregularly shaped, it’s not immediately clear what the “opposite” sides are.

The segment joining points 1 and 2 is opposite the segment joining points 4 and 5. The segment joining points 2 and 3 is opposite the segment joining points 5 and 6.The segment joining points 3 and 4 is opposite the segment joining points 6 and 1. If the hexagon were a regular hexagon, opposite sides would be parallel.

The theorem is usually illustrated with something like the figure below.

Opposite sides share the same color. The blue, green, and red dots inside the ellipse are the intersections of the blue sides, the green sides, and the red sides respectively. And as Pascal predicted, the three points are colinear.

The statement of Pascal’s theorem above is incomplete. We have to look at where the lines containing the sides intersect, not where the sides intersect. In the image above, the lines intersect where the line segments intersect, but this doesn’t always happen.

The Wikipedia article on Pascal’s theorem says “the three pairs of opposite sides of the hexagon (extended if necessary) meet at three points which lie on a straight line.” The parenthetical remark to extend the sides “if necessary” could lead you to think that needing to extend the sides is the exceptional case. It’s not; it’s the typical case.

The graph above is typical of presentations of Pascal’s theorem, but not typical of randomly selected points on an ellipse. I wrote a program to select random points on an ellipse and connect them as the theorem requires. The title of the plot above is “Run 24” because that was the first run to produce a typical illustration.

Here’s what the first run looked like.

In this example, all three intersection points are outside the ellipse. It’s hard to see the blue side on the bottom of the ellipse; it’s so short that the ellipse is practically flat over that distance and the blue line lies nearly on top of the black arc of the ellipse. This is a more typical example: usually one or more intersection points lies outside the ellipse, and usually one or more sides is hard to see.

Here’s an example that is even more typical.

Seeing this kind of plot first make me think there was a bug in my program. The shorter green side is hard to see, the intersection of the two green lines is lost between two points clumped close together, and the gray line connecting the three intersection points lies practically on top of a couple other lines.

Random examples and random tests

Random examples are complementary to clean classroom examples. The first image, Run 24, is typical in presentations for good reasons: it’s easy to see all the sides, and all the action happens in a small area. But random examples give you a better appreciation for the range of possibilities. This is very similar to software testing: some tests should be carefully designed and some should be chosen at random.

Conic sections

Pascal’s theorem applies to conic sections in general, not just ellipses. Here is an example with a parabola.

Randomly selected examples for parabolas are even less legible than random examples for ellipses. It’s common for lines to pile up on top of each other.

Projective geometry

Strictly speaking Pascal’s theorem is a theorem in projective geometry. It tacitly assumes that the lines in question do intersect. In the Euclidean plane two of the sides might be parallel and not intersect. In projective geometry parallel lines intersect “at infinity.” Or rather, there are no parallel lines in projective geometry.

With randomly selected points, the probability of two lines being parallel is 0. But it is possible that two lines are nearly parallel and intersect far from the ellipse. Some of the runs I made for this post did just this, like Run 9 below.

If you’ve got room for one illustration, you’d naturally use something like Run 24, but it’s good to know that things like Run 9 can happen too.

Related posts

A more convenient squircle equation

A few years ago I wrote several posts about “squircles”, starting with this post. These are shapes satisfying

|x|^p + |y|^p = 1

where typically p = 4 or 5. The advantage of a squircle over a square with rounded edges is that the curvature varies continuously around the figure rather than jumping from a constant positive value to zero.

Manuel Fernández-Guasti developed a slightly different shape also called a squircle but with a different equation

x^2 + y^2 = s^2 x^2 y^2 + 1

We need to give separate names to the two things called squircles, and so I’ll name them after their parameters: p-squircles and s-squircles.

As s varies from 0 to 1, s-squircles change continuously from a circle to a square, just as p-squircles varies do as p goes from 2 to ∞.

The two kinds of squircles are very similar. Here’s a plot of one on top of the other. I’ll go into detail later of how this plot was made.



Advantage of s-squircles

The equation for a p-squircle is polynomial if p is an even integer, but in general the equation is transcendental. The equation for an s-squircle is a polynomial of degree 4 for all values of s. It’s more mathematically convenient, and more computationally efficient, to have real numbers as coefficients than as exponents. The s-squircle is an algebraic variety, the level set of a polynomial, and so can be studied via algebraic geometry whereas p-squircles cannot (unless p is an even integer).

It’s remarkable that the two kinds of squircles are so different in the structure of their defining equation and yet so quantitatively close together.

Equal area comparison

I wanted to compare the two shapes, so I plotted p-squircles and s-squircles of the same area.

The area of a p-squircle is given here where n = 2. The area of an s-squircle is given here MathWorld where k = 1.

\begin{align*} A_1(p) &= 4\, \frac{\Gamma\left(1 + \frac{1}{p} \right )^2}{\Gamma\left(1 + \frac{2}{p} \right )} \\ A_2(s) &= 4\, \frac{E(\sin^{-1}s, s^{-1})}{s} \end{align*}

Here E is the “elliptic integral of the second kind.” This function has come up several times on the blog, for example here.

Both area function are increasing functions of their parameters. We have A1(2) = A2(0) and A1(∞) = A2(1). So we can pick a value of p and solve for the corresponding value of s that gives the same area, or vice versa.

The function A1 can be implemented in Mathematica as

    A1[p_] := 4 Gamma[1 + 1/p]^2/Gamma[1 + 2/p]

The function A2 is little trickier because Mathematica parameterizes the elliptic integral slightly differently than does the equation above.

    A2[s_] := 4 EllipticE[ArcSin[s], s^-2]/s

Now I can solve for the values of s that give the same area as p = 4 and p = 5.

    FindRoot[A2[s] == A1[4], {s, 0.9}]

returns 0.927713 and

    FindRoot[A2[s] == A1[5], {s, 0.9}]

returns 0.960333. (The 0.9 argument in the commands above is an initial guess at the root.)

The command

    ContourPlot[{x^2 + y^2 == 0.927713 ^2 x^2 y^2 + 1, 
        x^4 + y^4 == 1}, {x, -1, 1}, {y, -1, 1}]

produces the following plot. This is the same plot as at the top of the post, but enlarged to show detail.

The command

    ContourPlot[{x^2 + y^2 == 0.960333 ^2 x^2 y^2 + 1, 
        Abs[x]^5 + Abs[y]^5 == 1}, {x, -1, 1}, {y, -1, 1}]

produces this plot

In both cases the s-squircle is plotted in blue, and the p-squircle in gold. The gold virtually overwrites the blue. You have to look carefully to see a little bit of blue sticking out in the corners. The two squircles are essentially the same to within the thickness of the plotting lines.


The term “squircle” goes back to 1953, but was first used as it is used here around 1966. More on this here.

However, Fernández-Guasti was the first to use the term in scholarly literature in 2005. See the discussion in the MathWorld article.

Determining a conic by points and tangents

The first post this series said that a conic section has five degrees of freedom, and that any theorem that claims to determine a conic by less than five numbers is using some additional implicit information.

The second post looked at Gibbs’ method which uses three observations, and a variation on the method uses just one observation. The post explains where the missing information is hiding.

The third post looked at Lambert’s theorem which determines a conic section from two observations and again explains where the additional information comes from.

You could also determine a conic by an assortment of points and tangent lines (physically, a set of observations and velocities). You could specify four points on the conic and a line it must be tangent to. Or you could specify three points and two tangents, etc. See, for example, here.

As a general rule, any five reasonable pieces of information about a conic section are enough to determine it uniquely. The tedious part is writing down the exceptions to the general rule. For example, you can’t have three of the points lie on a line.

You can’t always get by with saying “I’ve got n degrees of freedom and n pieces of information, so there must be a solution.” And yet remarkably often you can.

Five points determine a conic section

This post is the first in a series looking at determining an orbit. Lambert’s theorem is often summarized by saying you can determine an orbit from two observations. This statement isn’t true without further assumptions, assumptions I plan to make explicit.

A solution to the two-body problem is an orbit given by a conic section, and the general equation of a conic section in the plane is

So conic sections have five degrees of freedom: if you know five out of the six coefficients A, B, C, D, E, and F then the equation above determines the sixth coefficient. And if you know five points on a conic section, there is an elegant way to find an equation of the conic. Given points (xi, yi) for i = 1, …, 5, the following determinant yields an equation for the conic section.

\begin{vmatrix} x^2 & xy & y^2 & x & y & 1 \\ x_1^2 & x_1 y_1 & y_1^2 & x_1 & y_1 & 1 \\ x_2^2 & x_2 y_2 & y_2^2 & x_2 & y_2 & 1 \\ x_3^2 & x_3 y_3 & y_3^2 & x_3 & y_3 & 1 \\ x_4^2 & x_4 y_4 & y_4^2 & x_4 & y_4 & 1 \\ x_5^2 & x_5 y_5 & y_5^2 & x_5 & y_5 & 1 \\ \end{vmatrix} = 0

This means that five observations are enough to determine a conic section, and since Keplerian orbits are conic sections, such an orbit can be determined by five observations. How do we get from five down to two?

Astronomical observations have more context than merely points in a plane. These observations take place over time. So we have not only the positions of objects but their positions at particular times. And we know that the motion of an object in orbit is constrained by Kepler’s laws. In short, we have more data than (x, y) pairs; we have (x, y, t) triples plus physical constraints.

We also have implicit information, and future posts in this series will make this implicit information explicit. For example, suppose you’re planning a trajectory to send a probe to Mars. The path of the probe will essentially be an orbit around the sun. You can determine this orbit by two observations: the position of Earth when the probe leaves and the position of Mars when it arrives. This orbit is not simply an ellipse passing through two points. It is an ellipse with one focus at the sun. I intend to unpack this in a future post, or series of posts, making implicit data explicit.

When I write a series of blog posts, the post don’t always come out consecutively. I expect I’ll write about other topics in between posts in this series.

Update: The next post in the series considers Gibbs’ method of determining an orbit from three observations (plus two other pieces of information). The post after that is about Lambert’s theorem.

Related posts

How eccentricity matters

I wrote last week that the eccentricities of planet orbits in our solar system do not effect the shape of the orbit very much. Here’s a plot of all the orbits, shifted to have the same center and scaled to have the same minor axis.

However, the planet orbits do not have a common center. The eccentricity of an orbit doesn’t affect its shape as much as its position. Eccentric orbits are off-center. That’s literally what eccentric means.

Kepler’s laws say that each planet orbits in an ellipse with the sun at one focus of that ellipse. That means the more eccentric an orbit is, the further the center of the orbit is from the sun.

If a planetary orbit has semi-major axis a and the foci are a distance c from the center, then the eccentricity e equals c/a. If we scale all the planetary orbits so that they each have a semi-major axis equal to 1, then e = c, i.e. the eccentricity equals the distance from each focus to the center.

Imagine the sun as the center of our coordinate system and that each planet’s orbit is aligned so that its major axis is along the x axis. Each orbit has the sun, i.e. the origin, as a focus, and so the center of each orbit is at –e where e is the eccentricity of that orbit. Here’s the plot above redone to fix the sun rather than to fix the center. The black dot in the center is the sun.

Here is the same plot with only Venus and Pluto.

The orbit of Venus is essentially a circle centered at the sun. The orbit of Pluto is an ellipse with major axis about 3% longer than its minor axis. It’s hard to see that the shape of Pluto’s orbit is not a circle, but it’s easy to see that the orbit is off-center, i.e. eccentric.

This post explains why moderately large eccentricities do not have much impact on the aspect ratio of an ellipse.

The image below from this post shows an ellipse with eccentricity 0.8. The two foci are far from the center, and yet the the aspect ratio is 3 : 5. It’s obviously an ellipse, but the foci are further apart than you might imagine.


Directrix of a conic

The most common way to define an ellipse geometrically is as the set of points whose distances to two foci sum to a constant. There is another way, however, to define an ellipse that generalizes to include the two other conic sections, parabolas and hyperbolas.

You can define a conic section as the set of points whose distance to a focus equals a constant multiple of the distance to a line called the directrix. This multiple is denoted e for eccentricity. If 0 < e < 1 you get an ellipse. If e = 1 you get a parabola, and if e > 1 you get a hyperbola [1].

The previous post defined the latus rectum for an ellipse. More generally, the latus rectum is the chord through the focus and parallel to the directrix.

And with this definition, you can define the latus rectum for each of the conic sections.


Given an ellipse with equation

x²/a² + y²/b² = 1

where a > b, the foci are at ± c where c = √(a² – b²). The eccentricity is e = c/a.

Consider the focus at –c. If the directrix is the line x = –d then the distance from the focus (-c, 0) to left vertex of the ellipse at (-a, 0) equals e times the distance from (-a, 0) to the point (-d, 0) on the directrix, and so

ac = (c/a)(da)

and we find d = a²/c.

In the plot below, the green vertical line to the left of the ellipse is the directrix. The red vertical line through the focus is the latus rectum. The length of the orange segment from the focus to the ellipse should be e times the length of the segment from the point on the ellipse to the directrix.


For a parabola with equation

= 4ax

with a > 0, the focus is at (a, 0) and the directrix is the line x = –a. The eccentricity of a parabola is 1.

Here again the green vertical line to the left of the parabola is the directrix and the red vertical line through the focus is the latus rectum. The two dashed orange lines have the same length.


Given a hyperbola with equation

x²/a² – y²/b² = 1

where a > b, the foci are at ± ae where the eccentricity is e = √(1 + b² / a²).

Let d = /c. Then either the line x = d or the line x = –d could be used as the directrix.

As before the green vertical line is the directrix and the red vertical line through the focus is the latus rectum. The lengths of the two dashed orange lines are proportional, and the proportionality constant is the eccentricity e.

Related posts

[1] The case e = 0 gives a circle, but now the definition doesn’t apply directly. The circle is the limit as e goes to 0 and the directrix moves further and further away. Projective geometry gives a way to rigorously say the directrix is a line at infinity without taking limits.