# Longest cylinder of specified radius in a given cuboid

Find the maximum height (in exact value) of a cylinder of radius $x$ so that it can completely place into a $100 cm \times 60 cm \times50 cm$ cuboid.

This question comes from http://hk.knowledge.yahoo.com/question/question?qid=7012072800395.

I know that this question is equivalent to two times of the maximum height (in exact value) of a right cone of radius $x$ so that it can completely place into a $50 cm \times$ $30 cm \times 25 cm$ cuboid whose the apex of the right cone is placed at the corner of the cuboid, but I still have no idea until now.

-
Please don't put subjective assessments of the difficulty of the question, such as "tricky" or "challenging", in the title. – joriki Aug 4 '12 at 20:59
Why not? It is no doubt that this question is challenging for most people. Moreover, does the title really break the rule in MSE? – doraemonpaul Aug 4 '12 at 21:09
No, no rule, I just kindly asked you not to do it :-) But seriously, if you've given it serious consideration and you still think there's reason to believe that most people will find this challenging, and you feel that that's valuable information to have in the title, I guess that's OK; but I keep seeing questions entitled "tricky X" and in most cases it's obvious that the OP has no idea what's tricky for other people. – joriki Aug 4 '12 at 21:36
What have you tried? – Code-Guru Aug 4 '12 at 21:58
looks trivial to me! – Mercy King Aug 5 '12 at 15:43

Here's a possibly-wrong approach ...

Center a "short" cylinder at the cuboid's center, oriented along a diagonal. Elongate the cylinder ---in each direction--- until it collides with a face, say the "top" (and, at the other end, the "bottom"). Letting the cylinder scrape against the top (and bottom) face(s), continue elongating the cylinder ---such that the projection of its axis into the top face coincides with the face's diagonal--- until it collides with a second (pair of) face(s). Finally, letting the cylinder scrape those faces, elongate in the only dimension allowable until it collides with the final (pair of) face(s).

Symbolically ...

Let the cuboid have dimensions $2a$, $2b$, $2c$; center it at the origin, and let its edges be axis-aligned. Let the cylinder have radius $s$. (I use "$r$" below for a different parameter.)

Taking $P = p \; ( a, b, c )$ to be the center of one end of the "short" cylinder, we elongate the cylinder (that is, we increase $p$) until it collides with the walls $x=\pm a$; this happens when

$$P_x + s \frac{P_x}{|P|} = a \qquad (1)$$

Let $p_\star$ be the value of $p$ solving $(1)$.

Now, let $Q := p_\star \; ( a, b, c ) + q \; ( 0, b, c )$ take over as the center of the end of the cylinder; we elongate until the cylinder hits the walls $y=\pm b$:

$$Q_y + s \frac{Q_y}{|Q|} = b \qquad (2)$$

Writing $q_\star$ for the appropriate value of $q$ solving $(2)$, we finish with cylindrical endpoint $R := p_\star \; ( a, b, c ) + q_\star\; ( 0, b, c ) + r ( 0, 0, c )$ until

$$R_z + s \frac{R_z}{|R|} = c \qquad (3)$$

when $r = r_\star$. Then

$$\ell = 2|R| = 2\sqrt{\; p_\star^2 \; a^2 + \left( p_\star + q_\star \right)^2 \; b^2 + \left( p_\star + q_\star + r_\star \right)^2 \; c^2 \; }$$

may (or may not) be the length of the longest cylinder in the cuboid. At least, it should be a "local maximum".

As for solving $(1)$, $(2)$, $(3)$ ...

For $(1)$, defining $d := \sqrt{a^2+b^2+c^2}$, we have

$$p a + s \frac{p a}{p d} = a \qquad \to \qquad p_\star = 1 - \frac{s}{d}$$

For $(2)$, we have

$$(p_\star+q) b + \frac{s(p_\star + q )b}{\sqrt{p_\star^2 a^2 + (p_\star + q )^2(b^2+c^2)}} = b$$ $$\to \qquad s(p_\star + q ) = \left(1-p_\star-q\right)\;\sqrt{p_\star^2 a^2 + (p_\star + q )^2(b^2+c^2)}$$ $$\to \qquad s^2 (p_\star + q )^2 = \left(1-p_\star-q\right)^2\;\left( p_\star^2 a^2 + (p_\star + q )^2(b^2+c^2) \right)$$

which makes $q_\star$ the root of a quartic polynomial. The same is true for $r_\star$. I'll leave the sorting-out of those roots to the reader.

-

Does the $x$ axis-aligned? Would it possible to have $x=0$? The only thing want to mention is the maximum length of a line within the bounded space would be the diagonal, based on the metric property.

-
If you mean that the cylinder's flat faces have to be parallel to a side of the box, the question would be trivial, since for each of the three cases the max r is when the cylinder extends all the way between the faces of the box. Your statement about the max r is correct: the length of the diagonal is an (unachievable) max r for actual nondegenerate cylinders, and to approach that max r would mean using small x going to 0. Still, seems more work to do to get max r as a function of x, likely a piecewise function. – coffeemath Oct 18 '12 at 18:47

A beginning:

Let $a_i>0$ $\>(1\leq i\leq 3)$ be the dimensions of the box. Then we are looking for a unit vector ${\bf u}=(u_1,u_2,u_3)$ in the first octant and a length $\ell>0$ such that $$\ell u_i+2 x\sqrt{1-u_i^2}=a_i\qquad(1\leq i\leq 3)\ .$$ When $x$ is small compared to the dimensions of the box one might begin with $$\ell^{(0)}:=d:=\sqrt{a_1^2+a_2^2+a_3^2}\ ,\qquad u_i^{(0)}:={a_i\over d}\quad(1\leq i\leq3)$$ and do a few Newton iterations in order to obtain an approximate solution.

-