The Money Mustache Community

Learning, Sharing, and Teaching => Ask a Mustachian => Topic started by: Bikesy on May 18, 2017, 04:13:22 AM

Title: Need help writing an equation for work
Post by: Bikesy on May 18, 2017, 04:13:22 AM
I figured some of the math wiz kids here may be able to help as this is way beyond my high school algebra knowledge.  I work in operations management and need to figure out how to maximize the size of an item I can fit in a tray/tote.  Container is 37"x 28" and open top.  Currently we are spec'd in such a way that the maximum length item that can be placed in the container is 37".  Clearly though, if a longer item is only 2" wide it could easily fit on an angle.  I'm looking for an equation that would solve for max width when given a length for an item that would fit in the container.  Anyone care to take a stab?  I would also be interested to know of a way to build an excel function where the length and width are entered and it would say yes/no for fit.  if any clarification is needed just let me know.

Any help is greatly appreciated
Title: Re: Need help writing an equation for work
Post by: bop on May 18, 2017, 05:55:42 AM
The following article explains when one rectangle can fit in another:
http://www.jstor.org/stable/2691523 (http://www.jstor.org/stable/2691523).
You'll need a JSTOR account to view the entire article.  I'll try to summarize the main result.

Suppose that the container rectangle is a units by b units, where a is greater than or equal to b.  (In your case, a = 37 and b = 28.)  Suppose that the item rectangle is p units by q units, where p is greater than or equal to q.  Then the item will fit in the container if and only if either
(a)  p <= a and q <= b (the obvious case), or
(b)  p > a, q <= b, and ((a + b)/(p + q))^2 + ((a - b)/(p - q))^2 >= 2. 
See page 2 of the article.  The bottom of page 1 gives an equivalent form.  (In the final line of page 1, I believe the condition q <= b should be included.) 


Title: Re: Need help writing an equation for work
Post by: ToeInTheWater on May 18, 2017, 06:27:26 AM
will give the formula (tl,dr), then go through the trig

tl,dr:   formula for how long an item would fit, given a width W:
         (28-W*cos( atan(37/28) ) ) /cos( atan(37/28) )

box is 37 x 28, so the diagonal = 46.4  (a^2 + b^2 = c^2)

will use this to make sure the final formula works.  if you put in a very, very small width, it should say that an item 46.4 in will fit

then it's a lot of trig:

the angle of the diag (assuming 28 along the x-axis, 37 along the y) = 52.9 (rounding a bit, actually, it's arctan(37/28) = .923 rad = 52.89 deg)
what follows uses 52.9 deg, formula above uses the exact measure

******* side note, XL trig functions want the angle in rad, 1 deg = .01745 rad.  i find it easier to think of the setup in deg*********

so, how long of an item, with width W, would fit?

you'd place it along that diagonal, so it would touch the x-axis (the 28" side) at W * cos (52.9 deg)
or, if W = 2 in, then it hits the 28" side at 2*cos(52.9 deg) = 1.21 in   

in XL it's 2*cos(52.9*.01745), or 2*cos(atan(37/28))

the rest of the 28" side, then is 28-1.21 = 26.79
   (this is the "adjacent" side of the angle),
    so the Hypotenuse = 26.79 / cos(52.9 deg) = 44.3"
    which is how long the item can be

and if you put in a very small width (.01):
   it hits the 28" side at .006"
   the rest of that side = 28-.006 = 27.994
   which is the "adj" side of the triangle
   and hyp = 27.994 / cos(52.9 deg) = 46.3

note it also works "backwards"
we saw that a 2" width meant a 44.3" length would work
a 44.3" width means a 2" len would work.

   
think that's correct

you could also make the len & width of the box inputs into the ATAN function for different size boxes

hope this helps
b




Title: Re: Need help writing an equation for work
Post by: KarefulKactus15 on May 18, 2017, 06:47:43 AM
Idk why I clicked this.

But it left me feeling very uneducated....  lol
Title: Re: Need help writing an equation for work
Post by: NextTime on May 18, 2017, 07:38:34 AM
Pythagorean Theorem
Title: Re: Need help writing an equation for work
Post by: Bikesy on May 18, 2017, 09:59:27 AM
Guys this awesome! Thank you so much.   And yes I do feel uneducated now lol.  This has potential to make a major positive impact on my work.  Thank you for taking the time to help out.  Just out of curiosity, do you guys use trig like this in your jobs or just have a love of math?
Title: Re: Need help writing an equation for work
Post by: With This Herring on May 18, 2017, 10:17:07 AM
Semi-joking:
As the box is open, you could also fit those items in at a 90o angle and just have them all on end.  Then you would only need to worry about the dimensions of their narrowest sides!  (Picture a box full of sticks, with all the sticks crammed in vertically, but many poking way past the top of the box.)
Title: Re: Need help writing an equation for work
Post by: omachi on May 18, 2017, 10:30:43 AM
Pythagorean Theorem

Won't quite work because objects have thickness. The trig answer looks correct on cursory inspection.

Semi-joking:
As the box is open, you could also fit those items in at a 90o angle and just have them all on end.  Then you would only need to worry about the dimensions of their narrowest sides!  (Picture a box full of sticks, with all the sticks crammed in vertically, but many poking way past the top of the box.)

This was my first thought, too. And if the object shouldn't poke out of the box, adding a maximum height to the box would still let you get even bigger items in than the 2D trig answer by laying it diagonally and not flat, with one side up and the other down.
Title: Re: Need help writing an equation for work
Post by: Bikesy on May 18, 2017, 10:32:26 AM
Semi-joking:
As the box is open, you could also fit those items in at a 90o angle and just have them all on end.  Then you would only need to worry about the dimensions of their narrowest sides!  (Picture a box full of sticks, with all the sticks crammed in vertically, but many poking way past the top of the box.)

Ohhh...Really thinking "outside the box", I like it!  Max height is somewhere around 24" due to physical constraints on where these containers go.  Also sidewall height is only 5" or so, so an item on end could potentially be thrown out.
Title: Re: Need help writing an equation for work
Post by: ToeInTheWater on May 18, 2017, 10:38:29 AM
Quote
Just out of curiosity, do you guys use trig like this in your jobs or just have a love of math?

just a love of math....

plus, when i first started working it, it was giving me obviously wrong answers (turned out to be the RAD/DEG bit from XL)
so i just HAD to work it all the way through...

b
Title: Re: Need help writing an equation for work
Post by: RWD on May 18, 2017, 10:48:46 AM
Idk why I clicked this.

But it left me feeling very uneducated....  lol

Same here, haha. And I have a minor in mathematics!