title: How to check if a box fits into another box (any rotations allowed)
body: <p>Suppose I have two boxes (each of them is a <a href="http://en.wikipedia.org/wiki/Rectangular_cuboid" rel="nofollow noreferrer">rectangular cuboid</a>, <em>aka</em> rectangular parallelepiped). I need to write a function that decides if the box with dimensions <em>(a, b, c)</em> can fit into the box with dimensions <em>(A, B, C)</em>, assuming any rotations by any angles are allowed (not only by 90°).</p>
  
  <p>The tricky part is the edges of the inner box may be not parallel to corresponding edges of the outer one. For example, a box that is very thin in the dimensions <em>(a, b)</em> but with length <em>1 &lt; c &lt; √3</em> can fit into a unit cube <em>(1, 1, 1)</em> if placed along its main diagonal.</p>
  
  <p>I've seen questions <a href="https://stackoverflow.com/q/16703854/3051002">[1]</a>, <a href="https://stackoverflow.com/q/16839489/3051002">[2]</a> but they seem to cover only rotations by 90°.</p>