Message Boards Message Boards

Show cylinders of different sizes in a Manipulate expression?

GROUPS:

Hello everyone. I have list containing parameters, something like this

list = {{1, 1}, {2, 2}}

I want to show n cylinders in a Manipulate expression, where n is equal to Length[list].

I tried this:

Manipulate[
  Show[
    {Graphics3D[
      {Red, 
       For[u = 1, u <= Length[list], u++, 
         {
            temp = list[[u]],
            Cylinder[{{par1, par2, par3}, {par1, par2, par3 + temp[[1]]}}, temp[[2]]]
          }]
       }, 
       PlotRange -> {{-5, 5}, {-5, 5}, {0, 20}}, 
       Boxed -> True, 
       ImageSize -> {300, 300}]}],
   ControlPlacement -> Left]

But this doesn't work. Please help me.

Also, how I can set a separate control for every cylinder {1 <= par1 <= 3, 1 <= par2 <= 3, 1 <= par3 <= 3}?

POSTED BY: Andrey Berzhinski
Answer
2 months ago

Something like this?

Manipulate[
 Graphics3D[{Red, Opacity[.5], 
   Table[Cylinder[{{par1, par2, par3}, {par1, par2, par3 + u[[1]]}}, 
     u[[2]]],
    {u, list}]},
  PlotRange -> {{-5, 5}, {-5, 5}, {0, 20}}, Boxed -> True, 
  ImageSize -> {300, 300}],
 {par1, 1, 3}, {par2, 1, 3}, {par3, 1, 3}]
POSTED BY: Gianluca Gorni
Answer
2 months ago

Group Abstract Group Abstract