(*減衰振動*)

Clear["Global`*"]
ans1 =  NDSolve[{x''[t] + 2*gamma*x'[t] +　(*グラフ*)
      omega^2*x[t] ==0,x[0] == 3,
 x'[0] ==0},x,{t,0,11}]/.
          {gamma->.5,omega->4}
x1 = x/.First[ans1]
gra1 = Plot[x1[t],{t,0,8},PlotRange ->{-3,3}]

gifs1 = Animate[
  locy[t_] := x1[t];
  locx[t_] := Abs[(Sqrt[9- ((x1[t])^2)])];
p1=Polygon[{{-3,-.3},{0,-.3},{0,.3},{-3,.3}}];(*壁左*)
p2=Polygon[{{3,-.3},{4,-.3},{4,.3},{3,.3}}];(*壁右*)
Graphics[{Thick,Brown,Line[{{0,0},{locx[t],locy[t]}}],p1,p2,
Text[StyleForm["上から見た図",FontSize->20,
FontWeight->"Bold"],{-3,4}],
Text[StyleForm["ドア",FontSize->20,
FontWeight->"Bold"],{1,-1.5}],
Text[StyleForm["壁",FontSize->20,
FontWeight->"Bold"],{-1.5,1}],
Text[StyleForm["壁",FontSize->20,
FontWeight->"Bold"],{3.5,1}]},PlotRange -> {{-5,5},{-5,5}}],
{t,0,10,.1},AnimationRepetitions->1,AnimationRunning -> False]

Directory[]            (*gif書き出し*)
Export["door1.gif",gifs1]

"door1.gif"
(*過減衰*)

Clear["Global`*"]
ans2=  NDSolve[{x''[t] + 2*gamma*x'[t] +
      omega^2*x[t] ==0,x[0] == 3,
 x'[0] ==0},x,{t,0,11}]/.
          {gamma->2,omega->1}
x2 = x/.First[ans2]
gra2= Plot[x2[t],{t,0,8},PlotRange ->{-3,3}]

gifs2 = Animate[
  locy[t_] := x2[t];
  locx[t_] := Abs[(Sqrt[9- ((x2[t])^2)])];
p1=Polygon[{{-3,-.3},{0,-.3},{0,.3},{-3,.3}}];(*壁左*)
p2=Polygon[{{3,-.3},{4,-.3},{4,.3},{3,.3}}];(*壁右*)
Graphics[{Thick,Brown,Line[{{0,0},{locx[t],locy[t]}}],p1,p2,
Text[StyleForm["上から見た図",FontSize->20,
FontWeight->"Bold"],{-3,4}],
Text[StyleForm["ドア",FontSize->20,
FontWeight->"Bold"],{1,-1.5}],
Text[StyleForm["壁",FontSize->20,
FontWeight->"Bold"],{-1.5,1}],
Text[StyleForm["壁",FontSize->20,
FontWeight->"Bold"],{3.5,1}]},PlotRange -> {{-5,5},{-5,5}}],
{t,0,10,.1},AnimationRepetitions->1,AnimationRunning -> False]

Directory[]           (*gif書き出し*)
Export["door2.gif",gifs2]

(*臨界振動*)

Clear["Global`*"]
ans3=  NDSolve[{x''[t] + 2*gamma*x'[t] +
      omega^2*x[t] ==0,x[0] == 3,
 x'[0] ==0},x,{t,0,11}]/.
          {gamma->1,omega->1}
x3 = x/.First[ans3]
gra3= Plot[x3[t],{t,0,8},PlotRange ->{-3,3}]

gifs3 = Animate[
  locy[t_] := x3[t];
  locx[t_] := Abs[(Sqrt[9- ((x3[t])^2)])];
p1=Polygon[{{-3,-.3},{0,-.3},{0,.3},{-3,.3}}];(*壁左*)
p2=Polygon[{{3,-.3},{4,-.3},{4,.3},{3,.3}}];(*壁右*)
Graphics[{Thick,Brown,Line[{{0,0},{locx[t],locy[t]}}],p1,p2,
Text[StyleForm["上から見た図",FontSize->20,
FontWeight->"Bold"],{-3,4}],
Text[StyleForm["ドア",FontSize->20,
FontWeight->"Bold"],{1,-1.5}],
Text[StyleForm["壁",FontSize->20,
FontWeight->"Bold"],{-1.5,1}],
Text[StyleForm["壁",FontSize->20,
FontWeight->"Bold"],{3.5,1}]},PlotRange -> {{-5,5},{-5,5}}],
{t,0,8,.1},AnimationRepetitions->1,AnimationRunning -> False]

Directory[]           (*gif書き出し*)
Export["door3.gif",gifs3]