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 was playing around with Manipulate to demonstrate simple geometric idea of conic sections and put this little sample together. When i move the slider it moves my plane, which is what I expect. However, when I let go of the slider, the graphics are rescaled. So how I stop that? I have set the PlotRange and AspectRatio, so I don't understand why the scale is changing.

Manipulate[
  plot = Plot3D[n, {x, -1, 1}, {y, -1, 1},
    AspectRatio->1, PlotRange->{{-1, 1}, {-1, 1}}, Mesh->False];
  cone = Graphics3D[{Opacity[0.3], Cone[{{0, 0, -1}, {0, 0, 1}}, 1]},
    PlotRange->{{-1, 1}, {-1, 1}}, AspectRatio->1];
  Show[{plot, cone}, AspectRatio->1],
  {{n, 0}, -1, 1}]
share|improve this question

2 Answers 2

 Manipulate[
 plot = Plot3D[n, {x, -1, 1}, {y, -1, 1}, BoxRatios -> 1, 
 PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}, Mesh -> False]; 
 cone = Graphics3D[{Opacity[0.3], Cone[{{0, 0, -1}, {0, 0, 1}}, 1]}, 
 PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}, BoxRatios -> 1]; 
 Show[{plot, cone}, BoxRatios -> 1], {{n, 0}, -1, 1}]

enter image description here

Update: Shorter version (that also avoids the constant dynamic updates in the previous version):

 Manipulate[Show[Plot3D[n, {x, -1, 1}, {y, -1, 1}, BoxRatios -> 1,
 PlotRange -> {-1, 1}, Mesh -> False],
  Graphics3D@{Opacity[0.3], Cone[{{0, 0, -1}, {0, 0, 1}}, 1]}],
{{n, 0}, -1, 1}]

or

 Manipulate[ Graphics3D[{LightBlue, 
   Polygon[{{-1, -1, n}, {-1, 1, n}, {1, 1, n}, {1, -1, n}}],
  Opacity[0.3], Cone[{{0, 0, -1}, {0, 0, 1}}, 1]},
  PlotRange -> {-1, 1}, BoxRatios -> 1],
 {{n, 0}, -1, 1}]
share|improve this answer
    
Excellents. Thanks for help. –  David McHarg Feb 4 '13 at 15:43
    
@DavidMcHarg, my pleasure. Welcome to Mathematica.SE. –  kguler Feb 4 '13 at 15:44
    
Never new about Initialization option, thanks for that. –  David McHarg Feb 4 '13 at 17:21
    
@Nasser, good point; added simpler/shorter versions that eliminate the need for Show. –  kguler Feb 4 '13 at 17:28

I updated my example to allow both the plane to be moved up/down and to change the inclination of the plane. I nice little example for conic sections, good for kids to see this stuff in action.

Manipulate[plot = Plot3D[ n x+m,{x,-1,1},{y,-1,1},
BoxRatios->1,PlotRange->{{-1,1},{-1,1},{-1,1}},Mesh->False];
cone = Graphics3D[{Opacity[0.3],Cone[{{0,0,-1},{0,0,1}},1]},
PlotRange->{{-1,1},{-1,1},{-1,1}},BoxRatios->1];
Show[{plot,cone},BoxRatios->1],
{{n,0,"Angle"},-1,1},{{m,0,"Intersection"},-1,1}
]

Conic sections

share|improve this answer
    
nice :)) ... +1. (You might consider adding TrackedSymbols -> {n, m}to avoid the constant flickering.) –  kguler Feb 4 '13 at 17:56
    
also for kids to enjoy: ice cream cones :) –  kguler Feb 4 '13 at 18:05

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.