I saw a lesson plan that had students filling different shaped bottles at a constant rate. The idea was to graph height vs. time to show the students how different shapes would produce different graphs, and especially the idea that most bottles would not produce a linear height vs. time function.

Would it be possible to "design" a bottle as a 3-d shape in Mathematica, and then use integration to animate filling it...?

  • $\begingroup$ Yes. The best starting point would be the Demonstrations site. For example, demonstrations about fluid tanks, surfaces of revolution, and volumes are all potential sources. There is a conference talk with code to get a resolved surface from a list of points that might be useful. $\endgroup$ – Brett Champion Mar 13 '12 at 20:33
  • $\begingroup$ @BrettChampion Your comment seems to me sufficiently complete to post as an answer. $\endgroup$ – Sjoerd C. de Vries Mar 13 '12 at 20:42
  • $\begingroup$ And welcome to Mathematica.SE, Tom! Hope you'll like it here. For one moment I thought my son Tom was playing tricks with me... ;-) Please don't forget to upvote any answers that are useful to you, and if one of these questions answers your question particularly well, accept it as the final answer by checking the checkmark next to the answer. You may to wait a few days before doing that. $\endgroup$ – Sjoerd C. de Vries Mar 13 '12 at 20:46
  • 5
    $\begingroup$ More or less exactly what you need can be found here : demonstrations.wolfram.com/FillingAContainerDefinedByACurve $\endgroup$ – Artes Mar 13 '12 at 20:48
  • $\begingroup$ Thanks to everyone , wow, that was fast... I just found that demonstration before the post was put up here... I hadn't dug deep enough at the demonstrations site... thanks to everyone already for the help, It's much appreciated! $\endgroup$ – Tom De Vries Mar 13 '12 at 20:52

Warning: It appears that in version 9 this tends to crash the kernel. Beware and save your work before trying!

Here's a starting point. It needs a lot more polish.

First, make a bottle:

{p1, p2, p3, p4} = Table[{i, 0.5}, {i, 4}];
if = Interpolation[{{0, 1/2}, p1, p2, p3, p4, {5, 1/2}}];

   Dynamic[{p1, p2, p3, 
     p4}, ({p1, p2, p3, p4} = #; 
      if = Interpolation[{{0, 1/2}, p1, p2, p3, p4, {5, 1/2}}]) &], 
   Dynamic@Plot[if[x], {x, 0, 5}, PlotRange -> {{0, 5}, {0, 1}}]],
   bottle = 
    RevolutionPlot3D[{if[x], x}, {x, 0, 5}, PlotStyle -> Opacity[0.5],
      Mesh -> None]]

Mathematica graphics

Then fill it and animate it:

volume = Derivative[-1]@FunctionInterpolation[if[x]^2, {x, 0, 5}]

    RevolutionPlot3D[{0.95 if[x], x}, {x, 0, 
      InverseFunction[volume][t]}, Mesh -> None, 
     PlotStyle -> Blue]], {t, 0.1, volume[5], 0.1}] // ListAnimate

Mathematica graphics

  • $\begingroup$ This fails on v7 with: RevolutionPlot3D::plln: Limiting value InverseFunction[InterpolatingFunction[{{0.,5.}},<<3>>,{Automatic}]][0.] in {x,0,(volume^(-1))[t]} is not a machine-size real number. >> any comment on that before I start digging? $\endgroup$ – Mr.Wizard Mar 14 '12 at 10:33
  • $\begingroup$ Wow, thanks for that, really amazing, I learned a lot there. I think for this to be useful to the students, they would have to have a slider that represented time, and be able to read the height. The already existing demonstration is excellent, but too "built". I'll be trying to see if I can pull it apart a bit so I can use it in a less "prepared" fashion. Thanks for your response! $\endgroup$ – Tom De Vries Mar 14 '12 at 17:55
  • $\begingroup$ I can't make this work on MMA v., OS X. $\endgroup$ – C. E. Jan 26 '14 at 15:20
  • $\begingroup$ @Pickett works fine here, just tried it. 9.0.1 OS X. $\endgroup$ – Szabolcs Jan 26 '14 at 15:21
  • $\begingroup$ @Pickett Yep, there were two problems which I fixed now. They didn't always show up depending on how you edited the vase. Unfortunately it still often crashes the kernel in v9. Doesn't crash in v8. $\endgroup$ – Szabolcs Jan 26 '14 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.