# About function with Manipulate and order of evaluation

I have many problems to understand how mathematica evaluates Manipulate[] when I use function before or inside Manipulate[] .

Could you give me a practise, a method to work with functions and Manipulate[].

This is my code :

TimeConstrained[
A16[poly_] :=
PolyhedronData[poly, "VertexCoordinates"][] // FullSimplify;
A7[poly_] :=
PolyhedronData[poly, "VertexCoordinates"][] // FullSimplify;
S1[r1_] := Sphere[A16[poly][], r1] // FullSimplify;
Spoly[poly_] := PolyhedronData[poly, "Circumsphere"];
polyw[poly_] := PolyhedronData[poly];
A167[poly_] :=
RegionIntersection[HalfLine[{0, 0, 0}, A16[poly] + A7[poly]],
Spoly[poly]] // FullSimplify;
C16 = RegionIntersection[S1[r1], Spoly[poly]];
reg = Region[A167[poly]];

Manipulate[
Show[
reg,
Graphics3D[{{Opacity[o], S1[r1], Spoly[poly]}, polyw[poly]}]],
{{r1, 1/10}, 0, 3}, {{o, 0.1}, 0, 1}, {{poly, "Dodecahedron"},
PolyhedronData[]},
Initialization :> (poly := "Dodecahedron")],
30]


UPDATE

I modified my code with the advice of Bill and I corrected 2 errors ,

now It works !

Manipulate[
A16[poly_] :=
PolyhedronData[poly, "VertexCoordinates"][] // FullSimplify;
A7[poly_] :=
PolyhedronData[poly, "VertexCoordinates"][] // FullSimplify;
S1[r1_] := Sphere[A16[poly], r1] // FullSimplify;
Spoly[poly_] := PolyhedronData[poly, "Circumsphere"];
polyw[poly_] := PolyhedronData[poly];
A167[poly_] :=
RegionIntersection[HalfLine[{0, 0, 0}, A16[poly] + A7[poly]],
Spoly[poly]] // FullSimplify;
C16 = RegionIntersection[S1[r1], Spoly[poly]];
reg = Region[A167[poly]];
Show[
reg,
Graphics3D[{{Opacity[o], S1[r1], Spoly[poly]}}],
polyw[poly]],
{{r1, 1/10}, 0, 3}, {{o, 0.1}, 0, 1}, {{poly, "Dodecahedron"},
PolyhedronData[]},
Initialization :> (poly := "Dodecahedron")],
30]


Thank you !

• I moved all of A16[poly_] :=...reg =... inside the Manipulate[ and before the Show and it seemed to work for me, at least until I chose tetrahedron. – Bill Jun 7 at 11:30

You defined A16 as the 16th vertex coordinate. However, for polyhedrons with fewer than 16 vertices that is undefined. Similarly for A7. I redefined these as the last and the "middle" vertices.

Manipulate[
vc = PolyhedronData[poly, "VertexCoordinates"];
Alast = Last@vc;
Amid = vc[[Floor[(Length[vc]-1)/2]]];
S1 = Sphere[Alast, r1];
Spoly = PolyhedronData[poly, "Circumsphere"];
polyw = PolyhedronData[poly];
A167 = RegionIntersection[
HalfLine[{0, 0, 0}, Alast + Amid],
Spoly] // FullSimplify;
C16 = RegionIntersection[S1, Spoly];
reg = Region[A167];
Show[
reg,
Graphics3D[{Opacity[o], S1, Spoly}], polyw],
{{r1, 0.1, Subscript["Radius", 1]}, 0, 3, 0.1,
Appearance -> "Labeled"},
{{o, 0.1, "Opacity"}, 0, 1, 0.1, Appearance -> "Labeled"},
{{poly, "Dodecahedron", "Polyhedron"}, PolyhedronData[]}] • Thank you for your answer, but I have another problem, when I open this file, Mathematica "evaluate" continually , the Output cell has a bold line down the whole height of the cell bracket ! You can see this screen capture : photos.app.goo.gl/h2M6MiRVerM4L8KL9 . I don't know why ! Could you help me ? – oli mat Jun 11 at 19:00
• Once evaluated, the Manipulate is continuously monitoring the controls so that it can respond ("The output is very much like a small applet or widget: it is not just a static result, it is a running program you can interact with."). If you no longer want it to monitor for activity, either Abort the evaluation or disable Dynamic Updating from the Evaluation menu. – Bob Hanlon Jun 11 at 19:33