I'm trying to plot the output of an equation in Graphics. However, Graphics does not appear to recognize the output; only explicitly writing the function into Graphics will work (see code below). Does anyone know a workaround for this?
Eqn1 = D[f[t], {t, 2}] + \[Omega]^2*f[t] == 0;
IC1 = f[0] == \[Alpha];
IC2 = (D[f[t], {t, 1}] == \[Gamma]) /. { t -> 0 };
Sol2 = Simplify[ DSolve[{Eqn1, IC1, IC2}, f[t], t] ];
x[\[Alpha]_, \[Gamma]_, \[Omega]_, t_] = Replace[ f[t], Sol2 ];
Manipulate[
Graphics[{
(* Frame *)
{
Directive[AbsoluteThickness[5], RGBColor[0.25, 0.25, 0.25]],
Line[{{-25, 0}, {50, 0}}],
Line[{{-25, 0}, {-25, 15}}]
},
{
RGBColor[0.25, 0.25, 0.75],
AbsoluteThickness[2.5],
Dashed, Line[{{0, 0}, {0, 15}}]
},
(* x(t) = 0 *)
{
Inset[Style["x(t) = 0", 20, FontFamily -> "Times"], {0, -5}]
},
(* Oscillating Masses *)
{
RGBColor[0, 0, 0.75],
EdgeForm[
Directive[AbsoluteThickness[2.5], Dashed, RGBColor[0, 0, 0]]],
Rectangle[ { (x[\[Alpha], \[Gamma], \[Omega], tmax]) + 5 ,
0 }, { (x[\[Alpha], \[Gamma], \[Omega], tmax]) - 5 , 10 } ]
},
(* The Spring *)
{
ParametricPlot[ {
sex/(
2 \[Pi])*((x[\[Alpha], \[Gamma], \[Omega], tmax]) + 25) -
25, 5 + 2.25*Sin[10*sex] },
{sex, 0, 2 \[Pi]},
PlotStyle -> {
Directive[RGBColor[0, 0, 0], AbsoluteThickness[2.5]]
},
Axes -> None][[1]]
}
(* Graphics *)}],
Style["", Bold, 14, FontFamily -> "Times"],
{{\[Alpha], -10, Style["\[Alpha]", 16, FontFamily -> "Times"]}, -10,
10, 0.01, ImageSize -> Medium, Appearance -> "Labeled"},
Style["", Bold, 14, FontFamily -> "Times"],
{{\[Gamma], 0, Style["\[Gamma]", 16, FontFamily -> "Times"]}, -10,
10, 0.01, ImageSize -> Medium, Appearance -> "Labeled"},
Style["", Bold, 14, FontFamily -> "Times"],
{{\[Omega], 1.0,
Style["\[Omega] [rad. \!\(\*SuperscriptBox[\(s\), \(-1\)]\)]", 16,
FontFamily -> "Times"]}, 0, 10, 0.01, ImageSize -> Medium,
Appearance -> "Labeled"},
Style["Axis Parameters", Underlined, 14, FontFamily -> "Times"],
{{tmax, 10^-20, Style["time", 16, FontFamily -> "Times"]}, 10^-20,
120, ControlType -> Trigger, DefaultDuration -> 120.0,
DisplayAllSteps -> True, AnimationRate -> 1.0, ImageSize -> Medium,
Appearance -> "Labeled"},
ControlPlacement -> Left,
SaveDefinitions -> False,
TrackedSymbols :> {\[Alpha], \[Gamma], \[Omega], tmax}
(* Manipulate *)]
However, writing the function directly into Graphics does work.
Manipulate[
Graphics[{
(* Frame *)
{
Directive[AbsoluteThickness[5], RGBColor[0.25, 0.25, 0.25]],
Line[{{-25, 0}, {50, 0}}],
Line[{{-25, 0}, {-25, 15}}]
},
{
RGBColor[0.25, 0.25, 0.75],
AbsoluteThickness[2.5],
Dashed, Line[{{0, 0}, {0, 15}}]
},
(* x(t) = 0 *)
{
Inset[Style["x(t) = 0", 20, FontFamily -> "Times"], {0, -5}]
},
(* Oscillating Masses *)
{
RGBColor[0, 0, 0.75],
EdgeForm[
Directive[AbsoluteThickness[2.5], Dashed, RGBColor[0, 0, 0]]],
Rectangle[ { (\[Alpha] Cos[tmax \[Omega]] + (\[Gamma] Sin[
tmax \[Omega]])/\[Omega]) + 5 ,
0 }, { (\[Alpha] Cos[tmax \[Omega]] + (\[Gamma] Sin[
tmax \[Omega]])/\[Omega]) - 5 , 10 } ]
},
(* The Spring *)
{
ParametricPlot[ {
sex/(2 \[Pi])*((\[Alpha] Cos[tmax \[Omega]] + (\[Gamma] Sin[
tmax \[Omega]])/\[Omega]) + 25) - 25,
5 + 2.25*Sin[10*sex] },
{sex, 0, 2 \[Pi]},
PlotStyle -> {
Directive[RGBColor[0, 0, 0], AbsoluteThickness[2.5]]
},
Axes -> None][[1]]
}
(* Graphics *)}],
Style["", Bold, 14, FontFamily -> "Times"],
{{\[Alpha], -10, Style["\[Alpha]", 16, FontFamily -> "Times"]}, -10,
10, 0.01, ImageSize -> Medium, Appearance -> "Labeled"},
Style["", Bold, 14, FontFamily -> "Times"],
{{\[Gamma], 0, Style["\[Gamma]", 16, FontFamily -> "Times"]}, -10,
10, 0.01, ImageSize -> Medium, Appearance -> "Labeled"},
Style["", Bold, 14, FontFamily -> "Times"],
{{\[Omega], 1.0,
Style["\[Omega] [rad. \!\(\*SuperscriptBox[\(s\), \(-1\)]\)]", 16,
FontFamily -> "Times"]}, 0, 10, 0.01, ImageSize -> Medium,
Appearance -> "Labeled"},
Style["Axis Parameters", Underlined, 14, FontFamily -> "Times"],
{{tmax, 10^-20, Style["time", 16, FontFamily -> "Times"]}, 10^-20,
120, ControlType -> Trigger, DefaultDuration -> 120.0,
DisplayAllSteps -> True, AnimationRate -> 1.0, ImageSize -> Medium,
Appearance -> "Labeled"},
ControlPlacement -> Left,
SaveDefinitions -> False,
TrackedSymbols :> {\[Alpha], \[Gamma], \[Omega], tmax}
(* Manipulate *)]
Any suggestions for using the output in Graphics?