Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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...?

share|improve this question
    
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. –  Brett Champion Mar 13 '12 at 20:33
    
@BrettChampion Your comment seems to me sufficiently complete to post as an answer. –  Sjoerd C. de Vries Mar 13 '12 at 20:42
    
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. –  Sjoerd C. de Vries Mar 13 '12 at 20:46
5  
More or less exactly what you need can be found here : demonstrations.wolfram.com/FillingAContainerDefinedByACurve –  Artes Mar 13 '12 at 20:48
    
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! –  Tom De Vries Mar 13 '12 at 20:52
show 1 more comment

1 Answer

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}}];

Column[{
  LocatorPane[
   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}}]],
  Dynamic[
   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}]

Table[Rasterize@
   Show[bottle, 
    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

share|improve this answer
    
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? –  Mr.Wizard Mar 14 '12 at 10:33
    
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! –  Tom De Vries Mar 14 '12 at 17:55
    
I can't make this work on MMA v. 9.0.0.0, OS X. –  Pickett Jan 26 at 15:20
    
@Pickett works fine here, just tried it. 9.0.1 OS X. –  Szabolcs Jan 26 at 15:21
    
@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. –  Szabolcs Jan 26 at 15:34
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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