I dont know why dont work but I want to animate torsion prismatic beam.
a = 1; b = 2; L = 10; G = 1; dx = dy = dz = 0.25; J = 2.1849801331564294`;
Clear[x, y, z, T]; k = T/( G J);
phi = (32 G k a)/Pi^3 Sum[1/n^3 (-1)^((n - 1)/2) (1 - Cosh[n Pi y/(2 a)]/
Cosh[n Pi b/(2a)]) Cos[(n Pi x)/(2 a)], {n, 1, 10, 2}];
tauyz = -D[phi, x]; tauxz = D[phi, y];
gammayz = tauyz/G;
gammaxz = tauxz/G;
Rotate[{x_, y_, z_}, Theta_] := {x Cos[Theta] - y Sin[Theta],
x Sin[Theta] + y Cos[Theta], z};
Off[Graphics3D::"gprim"];
Do[Show[Graphics3D[Table[alpha = 0.5 k z;
p1 = p2;
p2 = Map[({x, y} = #;
Rotate[{x + 0 gammaxz/2,
y + 0 gammayz/2,
z + (x gammaxz + y gammayz)/
2}, alpha]) &,
Flatten[{Table[{x, -b/2}, {x, -a/2, a/2 - dx, dx}],
Table[{a/2, y}, {y, -b/2, b/2 - dy, dy}],
Table[{x, b/2}, {x, a/2, dx - a/2, -dx}],
Table[{-a/2, y}, {y, b/2, dy - b/2, -dy}]}, 1]];
n = Length[p2];
If[z == 0, Polygon[p2],
Table[Polygon[{p1[[i]], p2[[i]], p2[[Mod[i, n] + 1]],
p1[[Mod[i, n] + 1]]}], {i, 1, n}]], {z, 0, L, dz}],
ViewPoint -> {-1, 1, 1}, ViewVertical -> {0, 1, 0}, Axes -> True,
AxesLabel -> {"x", "y", "z"},
PlotRange -> {{-a, a}, {-b, b}, {0, L}}]], {T, 0, 1, 0.1}];
SelectionMove[
EvaluationNotebook[], All, GeneratedCell];
FrontEndTokenExecute["CellGroup"];
FrontEndTokenExecute["OpenCloseGroup"];
FrontEndTokenExecute["SelectionAnimate"];
Rotate
is a built-in function. You cannot redefine it just like that. Furthermore, lots of undefine variables and what's0 gammaxz
supposed to do? And as to animation, why the rather strange use of frontend tokens? Are you aware of theAnimate
function? $\endgroup$