0
$\begingroup$

This quest is motivated by this. If I wish to visualize 3 Graphics3D objects, I can do this:

Manipulate[
 Graphics3D[{Opacity[a], Sphere[], Opacity[b], Cone[], Opacity[c], 
   Cylinder[]}, Boxed -> False],
 {{a, 1, "Sphere"}, {1, 0}},
 {{b, 1, "Cone"}, {1, 0}},
 {{c, 1, "Cylinder"}, {1, 0}},
 ControlPlacement -> Left, FrameMargins -> 0]

(The only problem with this is that when nothing is selected, I can still see two ellipses which I don't want.)

If I now wish to visualize say, 10 different objects, I should use an array of opacities instead of a, b, c and so on. While trying to do this in the following way I get an error message that

Manipulate::vsform: Manipulate argument {{op[[1]],1,Sphere},{1,0}} does not have the correct form for a variable specification.

The code I used is:

op = {0, 0, 0};
Manipulate[
 Graphics3D[{Opacity[op[[1]]], Sphere[], Opacity[op[[1]]], Cone[], 
   Opacity[op[[1]]], Cylinder[]}, Boxed -> False],
 {{op[[1]], 1, "Sphere"}, {1, 0}},
 {{op[[2]], 1, "Cone"}, {1, 0}},
 {{op[[3]], 1, "Cylinder"}, {1, 0}},
 ControlPlacement -> Left, FrameMargins -> 0]

How can I fix this error?

$\endgroup$
  • $\begingroup$ I don't know if it is interesting for you, but this works : Manipulate[ Graphics3D[{Opacity[a[1]], Sphere[], Opacity[a[2]], Cone[], Opacity[a[3]], Cylinder[]}, Boxed -> False], {{a[1], 1, "Sphere"}, {1, 0}}, {{a[2], 1, "Cone"}, {1, 0}}, {{a[3], 1, "Cylinder"}, {1, 0}}, ControlPlacement -> Left, FrameMargins -> 0] $\endgroup$ – andre314 Aug 14 '18 at 15:39
  • $\begingroup$ Also, you can specify EdgeForm[None] at the beginning of your Graphics3D list to remove those ellipses. $\endgroup$ – Josh Bishop Aug 14 '18 at 17:20
1
$\begingroup$
Module[
 {pl = PolyhedronData["Archimedean"]},
 Manipulate[
  Evaluate[
   Graphics3D[
    {
     EdgeForm[None],
     Riffle[
      Array[Opacity[q[#]] &, 13],
      MapIndexed[
       Tooltip[Translate[
          First[
           PolyhedronData[#1]],
          10 {Mod[First[#2], 4], Quotient[First[#2], 4], 0}
          ], #1] &
       , pl
       ]
      ]
     }
    ]
   ]
  , Evaluate[Sequence @@ MapIndexed[{{q[First@#2], 1, #1}, 0, 1} &, pl]
   ]
  ]]

Mathematica graphics

$\endgroup$
1
$\begingroup$

Here is a programmatic approach, which populates the Manipulate function with shapes from a list I called objects. The approach is to use Checkbox[Dynamic[...]] to Pick the items from objects to include in the Graphics3D list.

With[{objects = {Sphere[], Cone[], Cylinder[]}},
 Manipulate[
  Graphics3D[Pick[objects, picks, 1], Boxed -> False],
  {{picks, Table[1, {Length[objects]}]}, ControlType -> None}, 
  Dynamic[Grid[Transpose[
    {Outer[Checkbox[Dynamic[picks[[#1]]], {0, 1}] &, 
     Range[Length[objects]]], ToString@*Head /@ objects}]]
  ], ControlPlacement -> Left, FrameMargins -> 0]
]

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.