2Dグラフ集
Manipulateの勉強ということで、2Dグラフを何種類か、さらに値もDynamicに変更できるようなものを作ってみました。
あとはこれの応用で3Dとかもいけると思います。
もう少しコードを簡略化できないかなぁ・・・
改行も多いですが90行ぐらい。
以下、需要などあるわけがないソースコード。
range = {{-5, 5}, {-5, 5}}; SetOptions[Plot, {ImageSize -> Medium, PlotRange -> range, LabelStyle -> Directive[Italic]}]; SetOptions[ParametricPlot, {ImageSize -> Medium, PlotRange -> range, LabelStyle -> Directive[Italic]}]; Manipulate[ range = {{-r1, r1}, {-r1, r1}}; SetOptions[Plot, PlotRange -> range]; SetOptions[ParametricPlot, PlotRange -> range]; Switch[f, "Sin", Plot[sy Sin[sx x + tx] + ty, {x, -r2, r2}, PlotLabel -> Style["y=" Sin["x"], Blue, 20]], "Cos", Plot[sy Cos[sx x + tx] + ty, {x, -r2, r2}, PlotLabel -> Style["y=" Cos["x"], Blue, 20]], "Tan", Plot[sy Tan[sx x + tx] + ty, {x, -r2, r2}, PlotLabel -> Style["y=" Tan["x"], Blue, 20]], "Cot", Plot[sy Cot[sx x + tx] + ty, {x, -r2, r2}, PlotLabel -> Style["y=" Cot["x"], Blue, 20]], "Involute", ParametricPlot[ {a sx (Cos[t] + t Sin[t]) + tx, a sy (Sin[t] - t Cos[t]) + ty}, {t, 0, r2}, PlotLabel -> Style[ {x = "a" (Cos[\[Theta]] + \[Theta] Sin[\[Theta]]), y = "a" (Sin[\[Theta]] - \[Theta] Cos[\[Theta]])}, Blue, 20]], "Cissoid", ParametricPlot[ {sx (a t^2/(1 + t^2)) + tx, sy (a t^3/(1 + t^2) + ty)}, {t, -r2, r2}, PlotLabel -> Style[ {x = ("at"^2)/(1 + "t"^2), y = ("at"^3)/(1 + "t"^2)}, Blue, 20]], "Conchoid", ParametricPlot[ {sx (a + b Cos[t]) + tx, sy (a Tan[t] + b Sin[t]) + ty}, {t, -r2, r2}, PlotLabel -> Style[ {x = "a" + "b" Cos[\[Theta]], y = "a" Tan[\[Theta]] + "b" Sin[\[Theta]]}, Blue, 20]], "Strophoid", ParametricPlot[ {sx ((a (t^2 - 1))/(t^2 + 1)) + tx, sy ((a t (t^2 - 1))/(t^2 + 1)) + ty}, {t, -r2, r2}, PlotLabel -> Style[ {x = ("a" ("t"^2 - 1))/("t"^2 + 1), y = ("at" ("t"^2 - 1))/("t"^2 + 1)}, Blue, 20]], "Lissajous", ParametricPlot[ {sx Cos[a t] + tx, sy Sin[b t + c] + ty}, {t, -r2, r2}, PlotLabel -> Style[ {x = Cos["at"], y = Sin["bt" + "c"]}, Blue, 20]] ](*switch end*), (* manipulate options*) { f, {"Sin", "Cos", "Tan", "Cot", "Involute", "Cissoid", "Conchoid", "Strophoid", "Lissajous"}, ControlType -> PopupMenu }, {a, 1, 10}, {b, 1, 10}, {c, 1, 10}, {{sx, 1, "x scale"}, 1, 10}, {{tx, 0, "x translate"}, -3, 3}, {{sy, 1, "y scale"}, 1, 10}, {{ty, 0, "y translate"}, -3, 3}, {{r1, 5, "DisplayRange"}, 1, 10}, {{r2, 2 Pi, "GraphRange"}, 1, 10}, ControlPlacement -> {Top, Top, Top, Top, Bottom, Bottom, Bottom, Bottom, Bottom, Bottom} ]