0
$\begingroup$

I generated the plot shown below using this code:

ContourPlot3D[
  {x^2 + y^2 == 2.4, 
   x^2 + y^2 - z^2 == 1,
   x^2 + y^2 + (-Sqrt[4.76] + z)^2 == 2.4,
   x^2 + y^2 == .5^2},
  {x, -10, 10}, {y, -10, 10}, {z, -10, 10},
  ContourStyle -> Opacity[.65]]

enter image description here

But what I want to do is create this:

equation1 = x^2 + y^2 == 2.4
constraint1 = -0.5 - Sqrt[4.76] <= z <= -Sqrt[4.76]

equation2 = x^2 + y^2 - z^2 == 1
constraint2 = - Sqrt[4.76] <= z <= Sqrt[4.76]

equation3 = x^2 + y^2 + (-Sqrt[4.76] + z)^2 == 2.4
constraint3 = Sqrt[4.76] <= z <= Sqrt[5.51]

equation4 = x^2 + y^2 == .5^2
constraint4 = Sqrt[5.51] <= z <= Sqrt[5.51] + 1.5

I want to plot the surfaces with the constraints given above, so I can get the figure I designed to print in 3D. I'm really confused about how to integrate the constraints in the plot. Any tips?

$\endgroup$
1
$\begingroup$

Please try this.

equation1 = x^2 + y^2 == 2.4;
constraint1 = -0.5 - Sqrt[4.76] <= z <= -Sqrt[4.76];
equation2 = x^2 + y^2 - z^2 == 1;
constraint2 = -Sqrt[4.76] <= z <= Sqrt[4.76];
equation3 = x^2 + y^2 + (-Sqrt[4.76] + z)^2 == 2.4;
constraint3 = Sqrt[4.76] <= z <= Sqrt[5.51];
equation4 = x^2 + y^2 == .5^2;
constraint4 = Sqrt[5.51] <= z <= Sqrt[5.51] + 1.5;

g1 = ContourPlot3D[
   Evaluate[equation1], {x, -10, 10}, {y, -10, 10}, {z, 
    constraint1[[1]], constraint1[[3]]}, 
   ContourStyle -> Opacity[.65]];

g2 = ContourPlot3D[
   Evaluate[equation2], {x, -10, 10}, {y, -10, 10}, {z, 
    constraint2[[1]], constraint2[[3]]}, 
   ContourStyle -> Opacity[.65]];

g3 = ContourPlot3D[
   Evaluate[equation3], {x, -10, 10}, {y, -10, 10}, {z, 
    constraint3[[1]], constraint3[[3]]}, 
   ContourStyle -> Opacity[.65]];

g4 = ContourPlot3D[
   Evaluate[equation4], {x, -10, 10}, {y, -10, 10}, {z, 
    constraint4[[1]], constraint4[[3]]}, 
   ContourStyle -> Opacity[.65]];

Show[{g1, g2, g3, g4}, PlotRange -> {{-10, 10}, {-10, 10}, {-10, 10}}]

enter image description here

$\endgroup$

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.