I would like to visualize a swing of the pendulum. I want to write a function springmass[z, nzigzag], which will draw the spring (line) and the swinging weight (rectangle) for an default total length z and a quantity of spring coils (nzigzag).
I should animate the motion with exactly this line:
Animate[Graphics[springmass[5 + Sin[?], 23],PlotRange -> {-9, 0}], {?, 0, 2 ?}]
That’s what I found on the internet:
With[{min = .4},
vspring[a0_, y10_, y20_] :=
Module[{a = a0, y1 = y10 + min, y2 = y20, n = 100},
h = (y2 - y1)/n;
yvalues = Table[k, {k, y1, y2, h}];
xvalues = Table[a Sin[(m ?)/2], {m, 0, n}];
Line[Transpose[{xvalues, yvalues}]]]]
and
With[{size = .2},
Animate[
Graphics[{
vspring[0.2, 0, 2 Sin[y]],
Red, Thickness[5 size], Line[{{-.5 size, 2 Sin[y]}, {.5 size, 2 Sin[y]}}]},
PlotRange -> {{-size, size}, {-2.2 , 2 size}}],
{y, -?, 0, 0.1}]]
But I have one question. I should use this line:
Animate[Graphics[springmass[5 + Sin[?], 23],PlotRange -> {-9, 0}], {?, 0, 2 ?}]
The vspring function of the internet code have 3 parameters and the “required” line (the function springmass) have 2 parameters. How can I change that?
Thanks for your help!!!

