# How fat is a triangle?

The slimness factor of a geometric shape in 2 dimensions is the ratio between the side-length of its smallest containing square and its largest contained square. This is an important factor in computational geometry. So the slimness of a square is 1, the slimness of a circle is $\sqrt 2$, but what is the slimness factor of a given triangle?

After trying unsuccessfully to solve this geometrically, I decided to try a purely analytical solution. Here it is:

The triangle

The fatness obviously does not depend on scale. Hence two parameters are sufficient to define the triangle. I choose as parameters an angle $\theta$ adjacent to the longest side and the ratio $D$ between the side next to that angle and the longest side. We have to find the fatness as a function of $\theta$ and $D$.

Normalize the triangle so that its longest side lies on the x axis, between $(0,0)$ and $(1,0)$. Define $\theta$ as the angle at the origin. Rotate the triangle such that $\theta$ is between $0^\circ$ and $90^\circ$. For brevity, let $C=\cos \theta$ and $S=\sin \theta$. $D$ is the length of the side starting at the origin, so that the 3rd vertex of the triangle is at $(DC,DS)$, where $0<D<1$, $0\leq C<1$ and $0\leq S<1$.

The slimness factor should be calculated as a function of the parameters $D$, $C$ and $S$.

The containing square

Consider the unit square $[0,1]\times[0,1]$. We want to transform it so that it contains the triangle. A general transformation of a point $(x,y)$ is: $(rcx+rsy+h, rsx-rcy+v)$ where: $r$ is the dilation factor, $s$ and $c$ are sine and cosine of the rotation angle (we can assume they are both in $[0,1]$ because of the rotational symmetry of the square), $h$ is horizontal translation and $v$ is vertical translation. So a general transformation of the unit square has the following corners:

• $(h,v)$
• $(rc+h,rs+v)$
• $(rs+h,-rc+v)$
• $(rc+rs+h, rs-rc+v)$

and the following sides:

• $s(x-h)=c(y-v)$
• $s(x-h-rs)=c(y-v+rc)$ which is the same as $s(x-h)=c(y-v)+r$
• $c(x-h)=-s(y-v)$
• $c(x-h-rc)=-s(y-v-rs)$ which is the same as $c(x-h)=-s(y-v)+r$

In order to contain the triangle, each vertex $(x,y)$ of the triangle must be in the 4 half-planes defined by the 4 sides of the square:

• $c(y-v)\leq s(x-h)\leq c(y-v)+r$
• $-s(y-v)\leq c(x-h)\leq -s(y-v)+r$

Now, substitute each of the 3 vertices of the triangle and get, for $(0,0)$, $(1,0)$ and $(DC,DS)$ respectively:

• $-cv\leq -sh\leq -cv+r$
• $sv\leq -ch\leq sv+r$
• $-cv\leq s-sh\leq -cv+r$
• $sv\leq c-ch\leq sv+r$
• $c(DS-v)\leq s(DC-h)\leq c(DS-v)+r$
• $-s(DS-v)\leq c(DC-h)\leq -s(DS-v)+r$

There are a total of 12 inequalities here. Our goal is to find the smallest $r$ such that there are $c,s,h,v$ satisfying all these 12 inequalities.

Removing some redundant inequalities and ordering, we get:

• $r\geq s+cv-sh$
• $cv-sh\geq 0$
• $r\geq c-ch-sv$
• $-ch-sv\geq 0$
• $r\geq s(DC-h)-c(DS-v)=sDC-cDS+cv-sh$
• $r\geq c(DC-h)+s(DS-v)=cDC+sDS-ch-sv$

To make $r$ as small as possible, we should select $h$ and $v$ such that inequalities 2 and 4 become zero. Then we remain with the following inequalities which $r$ must satisfy:

1. $r\geq s$
2. $r\geq c$
3. $r\geq cDC+sDS$

Here I am stuck: how can I solve this optimization problem?

The contained square

Again consider the unit square $[0,1]\times[0,1]$. Now we want to transform it so that it is contained in the triangle. The 4 corners of the square must satisfy the 3 inequalities dictated by the sides of the triangle, which are:

• $y\geq 0$
• $xDS\geq yDC$
• $(1-x)DS\geq (1-DC)y$

Substituting the 4 corners of the square gives the following 12 inequalities which r must satisfy, some of which are redundant:

• $-rc+v\geq 0$
• $v\geq 0$ (redundant)
• $rs+v\geq 0$ (redundant)
• $rs-rc+v\geq 0$ (redundant)

• $hDS\geq vDC$

• $(rc+h)DS\geq (rs+v)DC$
• $(rs+h)DS\geq (-rc+v)DC$ (redundant)
• $(rc+rs+h)DS\geq (rs-rc+v)DC$ (redundant)

• $(1-rc-h)DS\geq (1-DC)(rs+v)$

• $(1-h)DS\geq (1-DC)v$ (redundant)
• $(1-rc-rs-h)DS\geq (1-DC)(rs-rc+v)$
• $(1-rs-h)DS\geq (1-DC)(-rc+v)$ (redundant)

These imply the following 5 inequalities (note that this time the direction of the inequalities is inversed because we are looking to maximize $r$ subject to the inequalities):

1. $cr \leq v$
2. $0\leq hDS-vDC$
3. $(sDC-cDS)r \leq hDS-vDC$
4. $(s-sDC+cDS)r\leq DS-v-hDS+vDC$
5. $(s-c-sDC+cDC+sDS+cDS)r\leq DS-v-hDS+vDC$

Here, again, I am stuck...

The last step is just to divide the two $r$'s, but, how do I find each $r$?

Note

I am looking for a formula that gives fatness as a function of $\theta$ and $D$. However, if you think there is another pair of parameters by which it is more convenient to represent the fatness (e.g. the two smaller angles), then this is also welcome.

• It appears to me that you can make a triangle as slim as you wish. Consider a right-angled triangle with unit base and height h. The contained square would seem to have side < 1, while the containing square would have side of order h. By symmetry, I wouldn't be surprised if an equilateral triangle were the fattest. Jun 29, 2014 at 12:46
• Could you explain what do you use inscribed/circumscribed squares and not circles to define slimness? Using circles would make all the computations so much easier. Could you also add references to where this concept is used. Other than this, it's a nice question. Jun 30, 2014 at 0:13
• The problem of finding the containing square has been solved here. Aug 25, 2014 at 10:08
• Is there ever a case where the largest contained square does not rest on one side of the triangle?
– mhum
Aug 29, 2014 at 2:06
• If that "standard" definition in Computational Geometry cannot even used to calculate the slimness factor of a shape like a triangle in a simple manner, I would rather think of an alternative definition. Maybe one possibility to think about is to define the slimness factor as the excentricity of a Steiner ellipse. Aug 30, 2014 at 15:42

I do not think using squares is a good idea. If you use instead the ratio $r/R$ of the inradius to the circumradius, you get a very clean formula:
$$4\sin(A/2)\sin(B/2)\sin(C/2),$$ where $A, B, C$ are the angles of the triangle. See for instance here.

• And that gives easily an upper bound to the "square" slimness. Aug 31, 2014 at 19:26
• Note that the circumradius is not the radius of the smallest enclosing circle, so for obtuse triangles this is rather different from a slimness factor.
– Matt
Aug 31, 2014 at 21:49
• @Matt: Yes, of course, I was careless. For acute triangles you divide $r$ by the circumradius, otherwise, divide by the longest side. Aug 31, 2014 at 22:39
• @studiosus I didn't understand your last comment. Why does this describe the radius of the smallest containing circle? And how do you get from it to a formula of the slimness factor? Sep 1, 2014 at 11:43
• @Erel The smallest containing circle for an acute triangle is the circumcircle, while for an obtuse triangle it is the circle having the triangle's longest side as a diameter. For the intermediate case of right triangles, those two circles are the same. So you will have two formulas, one for acute/right triangles, and one for obtuse/right triangles.
– Matt
Sep 1, 2014 at 19:44

The containing square

If we imagine rotating the triangle by an angle $\theta$ and measuring the width (minimum $x$ coordinate to maximum $x$ coordinate, as could be measured with a vernier caliper), we get a width function $w(\theta)$ which can be expressed in terms of the side lengths $s_1,s_2,s_3$ and side headings $\phi_1, \phi_2, \phi_3$ as $$w(\theta)=\max\left( s_1\left|\cos(\phi_1-\theta)\right|, s_2\left|\cos(\phi_2-\theta)\right|, s_3\left|\cos(\phi_3-\theta)\right| \right).$$ (Note that the maximum of those three values, representing the side that extends from the minimum $x$ coordinate to the maximum $x$ coordinate, always equals the sum of the other two.)

A square whose sides have headings $\theta$ and $\theta+\pi/2$ can fit around the triangle iff its sides have length at least $q(\theta)=\max\left(w(\theta),w(\theta+\pi/2)\right)$.  The smallest containing square is $\min_\theta q(\theta)$.

Since $q$ is the maximum of six rectified sinusoids, its minimum must be at one of the values of $\theta$ where (at least) two maximal sinusoids meet.  There are at most six such values in $[0,\pi/2]$ ($q$ is periodic with period $\pi/2$) so they can be enumerated to find the minimum.

Geometric configurations of the minimal square: For triangles having at most one angle below $\pi/4$, there are two possible configurations: (1) One triangle vertex is in a corner of the square, with the other two vertices on the two far sides, and/or (2) two vertices of the triangle are on one side of the square, with the third vertex on the opposite side.  Triangles with two angles below $\pi/4$ use a third configuration: (3) The square has the triangle's long side as its diagonal.  For example, a triangle with $(s_1,s_2,s_3)=(6,9,9)$ yields configuration (1), while $(8,9,9)$ yields configuration (2), and $(14,9,9)$ yields configuration (3).

The contained square

Since every triangle is convex, the square is inside the triangle iff its four corners are in the triangle.

If a side of the triangle is untouched by the square's corners, a homothety (centered at the vertex where the two other sides meet) can enlarge the square while keeping it in the triangle.  Therefore, the maximal square's vertices touch all three sides of the triangle.

If two of the triangle sides are touched only at their common vertex (by square corner $A$), then the third triangle side can only be touched by corner $C$ (the corner diagonally opposite $A$).  In this case, the square is not maximal, as it can be rotated and enlarged while staying inside the triangle.  Therefore, at least three of the square's corners lie on the triangle.

If two corners of the square are on the same side (say $b$) of the triangle, then the square might be maximal.  It is easy to find the largest square that sits on side $b$: Either $b$ is one of the short sides of an obtuse triangle, in which case the largest square has a vertex at the obtuse angle, or else the altitude $h_b$ to side $b$ lies inside the triangle, in which case the largest square has its other two vertices on the other two sides of the triangle, and has a side length of half the geometric mean of the lengths of $h_b$ and $b$, namely $s=\frac{h_b b}{h_b + b}$.  By finding the largest square for each of the three sides of the triangle, we can easily find the largest of these three squares, which as we will soon see is indeed the maximal possible.

The only remaining case is that three corners of the square lie in the interiors of the three sides of the triangle, with the fourth corner strictly inside the triangle.  In this case, the square can again be rotated and enlarged.  This can be seen by considering the paths of the other corners of the square as two corners slide back and forth on two sides of the triangle: The paths are elliptical.  This means that the square can be moved so that two corners stay on the triangle, and (in at least one direction) the third corner will move into the interior of the triangle, so (like the first case above) the square is not maximal.

• In the containing square, you use a formula that depends on 6 parameters (3 angles and 3 side-lengths). Is it possible to find a closed-form formula that depends only on 2 parameters (e.g. 2 angles)? Sep 1, 2014 at 11:15
• It depends on what you mean by "closed-form". Since it is only piecewise differentiable, I don't think you can avoid the presence of constructs like "max" that correspond to an "if-then" in a program, although they can be hidden using closed-form constructs like "if A then B else C"$=B\,sgn(A)^2+C(1-sgn(A)^2)$. Given 2 angles $α_1,α_2$, you can assume a unit-diameter circumcircle and construct all the other parameters: $(s_1,s_2,s_3,\phi_1,\phi_2,\phi_3)=(sin(α_1),sin(α_2),sin(α_1+α_2),0,α_1+α_2,α_2)$. These two tricks should give you what you want.
– Matt
Sep 1, 2014 at 16:14

After all those appetizer comments of mine, the OP himself is asking for : what formula describes the slimness of a triangle, based on Steiner Ellipses? So it's time to feed some meat to the public :-)
Needed for the Steiner ellipse, or best fit ellipse, or ellipse of inertia (they are all similar) are the variances (in statistics terms) of moments of inertia (in physics terms). To calculate the latter, there are three possibilities:

1. Simplest case: all triangle weight is in the vertices $(x_1,y_1),(x_2,y_2),(x_3,y_3)$
2. The triangle consists of three rods and all weight is in there
3. The triangle is cut from a plate and the weight is distibuted uniformly over its area
The area point of view has been worked out in the reference Steiner Ellipses and Variances. At the last page of this reference is also the important statement that the best fit ellipse of a triangle is an inertial ellipse and is the inner Steiner ellipse. For simplicity, we shall adopt the weight at vertices case here. See the reference, or work out the second case yourself, if you want otherwise. $$\mu_x = (x_1+x_2+x_3)/3 \quad ; \quad \mu_y = (y_1+y_2+y_3)/3 \\ \sigma_{xx} = (x_1^2+x_2^2+x_3^2)/3 - \mu_x^2 = \frac{2}{9}(x_1^2+x_2^2+x_3^2-x_1x_2-x_1x_3-x_2x_3) \\ \sigma_{yy} = (y_1^2+y_2^2+y_3^2)/3 - \mu_y^2 = \frac{2}{9}(y_1^2+y_2^2+y_3^2-y_1y_2-y_1y_3-y_2y_3) \\ \sigma_{xy} = \left[(x_1-\mu_x)(y_1-\mu_y)+(x_2-\mu_x)(y_2-\mu_y)+(x_3-\mu_x)(y_3-\mu_y)\right]/3 = \\ \frac{1}{9}(2x_1 y_1 + 2x_2 y_2 + 2x_3 y_3 - x_1 y_2 - x_2 y_1 - x_2 y_3 - x_3 y_2 - x_1 y_3 - x_3 y_1)$$ The best fit ellipse of inertia is: $$\frac{\sigma_{yy}(x-\mu_x)^2 - 2\sigma_{xy}(x-\mu_x)(y-\mu_y) + \sigma_{xx}(y-\mu_y)^2} {\sigma_{xx}\sigma_{yy}-\sigma_{xy}^2} = 2$$ The eigenvalues of the covariance matrix (of inertia) are related to the axes of the ellipse: $$\left| \begin{matrix} \sigma_{xx}-\lambda & \sigma_{xy} \\ \sigma_{xy} & \sigma_{yy}-\lambda \end{matrix} \right| = 0 \qquad \Longleftrightarrow \qquad \lambda^2 - (\sigma_{xx}+\sigma_{yy})\lambda + (\sigma_{xx}\sigma_{yy}-\sigma_{xy}^2) = 0$$ Rename (Trace and Determinant): $$\mbox{Tr} = \sigma_{xx}+\sigma_{yy} \qquad ; \qquad \mbox{Det} = \sigma_{xx}\sigma_{yy}-\sigma_{xy}^2$$ Then the solutions are (very much real and positive): $$\lambda_{\pm} = \mbox{Tr}/2 \pm \sqrt{\left(\mbox{Tr}/2\right)^2 - \mbox{Det}}$$ The excentricity of the ellipse is: $$\epsilon = \sqrt{\frac{\lambda_{+}}{\lambda_{-}}} = \frac{\sqrt{\lambda_{+}\lambda_{-}}}{\lambda_{-}} = \frac{\sqrt{\mbox{Det}}}{\lambda_{-}} = \frac{\lambda_{+}}{\sqrt{\mbox{Det}}}$$ Which is the formula you asked for (hopefully).
(Un)fortunately I have only a program that generates pictures for the case that the weight of the triangle is uniformly distributed over its area (which anyway seems to be the more interesting): Update. It may be questioned if choosing one of the triangle views, as 3 vertices (1), as 3 rods (2), as a flat plate (3), has any influence on the slimness factor.
It can be easily proved that the center of gravity / midpoint of the triangle in all three cases is the same : $\mu_x = (x_1+x_2+x_3)/3 \; ; \; \mu_y = (y_1+y_2+y_3)/3$ . Now define the following quantities, where it is noted that the last two can be derived from the first one: $$s_{xy} = (x_1-x_2)(y_1-y_2)+(x_2-x_3)(y_2-y_3)+(x_3-x_1)(y_3-y_1) \\ s_{xx} = (x_1-x_2)^2+(x_2-x_3)^2+(x_3-x_1)^2 \quad ; \quad s_{yy} = (y_1-y_2)^2+(y_2-y_3)^2+(y_3-y_1)^2$$ Then the second order moments of inertia / variances in the vertex case can be rewritten as:
$\sigma_{xx} = s_{xx}/9$ , $\sigma_{yy} = s_{yy}/9$ , $\sigma_{xy} = x_{xy}/9$ .
Compare this with the quantities of the flat plate case in the abovementioned paper . Then it turns out that the formulas are very similar :
$\sigma_{xx} = s_{xx}/36$ , $\sigma_{yy} = s_{yy}/36$ , $\sigma_{xy} = s_{xy}/36$ .
Which means that the ellipse in the vertex case is larger than the ellipse in the flat plate case, twice as large to be precise, because $\sqrt{36/9}=2$ . In the flate plate case, we get the Steiner Inellipse and in the vertex case, we get the Steiner Outellipse . For the slimness factor, this makes no difference.

EDIT. Three Rods case. If I am right with my calculated ratio $3:6:12$ (instead of Matt's $3:8:12$) then we have the following picture for the $\color{green}{vertex}$ case, the $\color{blue}{rods}$ case and the flat $\color{red}{plate}$ case.
Conclusion: The slimness factor in all three cases is the same. Coordinate independence. The formula for the Trace can be rewritten as follows: $$\mbox{Tr} \sim (s_{xx}+s_{yy})/2 = (a^2+b^2+c^2)/2$$ Where $a,b,c$ are the lengths of the triangle edges, as usual. The Determinant is conjectured to be proportional to the square of the area of the triangle. MAPLE is invoked to confirm this:

A := simplify(s_xxs_yy-s_xy^2);
B := simplify(((x_2-x_1)(y_3-y_1)-(x_3-x_1)*(y_2-y_1))^2);
verify(A,3*B,equal);
true

Hence: $$\mbox{Det} \sim (s_{xx}s_{yy}-s_{xy}^2) = 3(2A)^2 = 12 A^2$$ Where $A$ denotes the Area of the triangle.

Quoting a comment: I don't see, where are the angles of the triangle in this formula?
With Heron's formula for the area $A$ and some algebra we find with the above: $$\lambda_{\pm} \sim \frac{a^2+b^2+c^2}{2} \pm \sqrt{a^4+b^4+c^4-(a^2b^2+b^2c^2+a^2c^2)}$$ The sine rule says that, with one and the same proportionality constant $K$ : $$a = K\sin(\alpha) \quad ; \quad b = K\sin(\beta) \quad ; \quad c = K\sin(\gamma)$$ Since in the (square root of) the quotient $\;\lambda_{+}/\lambda_{-}\;$ any proportionality constant will disappear, it is indeed possible to find a more "closed" formula for the Steiner based slimness factor, as a function of the angles only : simply replace $\;a,b,c\;$ by the corresponding $\;\sin(\alpha),\sin(\beta),\sin(\gamma)$ .

• I don't see, where are the angles of the triangle in this formula? Sep 2, 2014 at 19:20
• Very much hidden, I think. I'm sorry if this approach doesn't conform to your expectations; it is my best shot. Sep 2, 2014 at 19:27
• OK. Can your program calculate the slimness factor numerically, given angles? For example, if I want to plot a graph of the slimness factor of an isosceles triangle, as a function of the head angle, is this easy to do with your program? Sep 3, 2014 at 5:14
• @ErelSegalHalevi: Sine rule. WLOG , let $(x_1,y_1) = (0,0) , (x_2,y_2) = (1,0) , (x_3,y_3) = (x,y)$ . Then $\sin(\alpha)/\sqrt{(x-1)^2+y^2}=\sin(\beta)/\sqrt{x^2+y^2}=\sin(\gamma)/1$ . Solve for $x$ and $y$ and substitute in the above. With some ingenuity maybe it's possible to find more "closed" formulas; I don't know. Sep 3, 2014 at 10:34
• The ellipse areas seem to be in the ratio 3:8:12, for the flat plate case, the three equal mass rods case, and the vertex case respectively.
– Matt
Sep 4, 2014 at 8:03

Only one circle can be superscribed on a given triangle (i.e. only one circle can pass through the corner points of a triangle) and only one circle can be inscribed in any given triangle . If R1 and R2 are the radii of the the two circles , superscribed and inscribed , respectively ,then the slimness factor will equal R2/R1.................................When you inscribe (or superscribe ) a square in a triangle ,there can be many squares that can be inscribed (or superscribed)into or contained by(or contain) a triangle .So the concept of inscribed and superscribed squares , cannot be used to define the slimness of a triangle -- as this not yield an unique value .

• There are many squares that contain a triangle, but the definition is based on the smallest such square. There are many squares contained in a triangle, but the definition is based on the largest such square. So, the value is unique. Jul 2, 2014 at 9:36