Mathematica でカテナリー曲線を表現したいのですが、ハンギング ポイントの位置 (A、B)、ケーブルの重量、重力などの各パラメーターをユーザーが操作できるようにしたいと思います。
1 に答える
4
私は次のようにします:
まず、カテナリーを定義します。
catenary[x_] := a*Cosh[(x - c)/a] + y
a
これで、次を使用して、パラメータとこの曲線の数値をc
見つけることができます。y
FindRoot
Manipulate[
Module[{root},
(
root = FindRoot[
{
catenary[x1] == y1,
catenary[x2] == y2
} /. {x1 -> pt[[1, 1]], y1 -> pt[[1, 2]], x2 -> pt[[2, 1]], y2 -> pt[[2, 2]], a -> \[Alpha]},
{{y, 0}, {c, 0}}];
Show[
Plot[catenary[x] /. root /. a -> \[Alpha], {x, -2, 2},
PlotRange -> {-3, 3}, AspectRatio -> 3/2],
Graphics[{Red, Point[pt]}]]
)], {{\[Alpha], 1}, 0.001, 10}, {{pt, {{-1, 1}, {1, 1}}}, Locator}]
または、パラメーターを正確に解くこともできます。
solution = Simplify[Solve[{catenary[x1] == y1, catenary[x2] == y2}, {y, c}]]
次に、Manipulate でこのソリューションを使用します。
Manipulate[
(
s = (solution /. {x1 -> pt[[1, 1]], y1 -> pt[[1, 2]],
x2 -> pt[[2, 1]], y2 -> pt[[2, 2]], a -> \[Alpha]});
s = Select[s,
Im[c /. #] == 0 &&
Abs[pt[[1, 2]] - catenary[pt[[1, 1]]] /. # /. a -> \[Alpha]] <
10^-3 &];
Show[
Plot[catenary[x] /. s /. a -> \[Alpha], {x, -2, 2},
PlotRange -> {-3, 3}, AspectRatio -> 3/2],
Graphics[{Red, Point[pt]}]]
), {{\[Alpha], 1}, 0.001, 10}, {{pt, {{-1., 1.}, {1., 0.5}}},
Locator}]
ただし、このFindRoot
バージョンはより高速で安定しています。結果は次のようになります。
完全を期すために、次の 3 つのポイントでカテナリーを見つけることもできます。
m = Manipulate[
Module[{root},
(
root =
FindRoot[
catenary[#[[1]]] == #[[2]] & /@ pt, {{y, 0}, {c, 0}, {a, 1}}];
Show[
Plot[catenary[x] /. root, {x, -2, 2}, PlotRange -> {-3, 3},
AspectRatio -> 3/2],
Graphics[{Red, Point[pt]}]]
)], {{pt, {{-1, 1}, {1, 1}, {0, 0}}}, Locator}]
于 2012-06-03T19:08:55.333 に答える