# Manipulating a catenary in Mathematica

I have a catenary curve in Mathematica, and I wanted to add a variator (dimmer) with Manipulate, so that the user can modify the value of the x/y-coordinate of the hanging-points A, B and the point C on the curve. With my current code, I can just modify these values with the locator, but I can't see the current value and cannot set one directly.

Is there a solution, so that I delete the rest of the curve, the part above the hanging-points A and B?

Here is my code till now:

catenary[x_] := a*Cosh[(x - c)/a] + y

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}
]

-
You've seen this and this? –  Ｊ. Ｍ. Jun 17 '12 at 14:47
Welcome to Mathematica.SE! I noted that you directly accepted the first answer, which was given only minutes after your question was posted. It is usually better to wait a bit (a day or so is not uncommon) in order to entice more people to provide an answer. –  Sjoerd C. de Vries Jun 17 '12 at 15:08
I completely agree with @SjoerdC.deVries (+1 ;-) ), you should wait some time, no need to rush. –  Vitaliy Kaurov Jun 17 '12 at 15:30
Do you need input field to type the coordinate or just the slider to drag around? I just do not see the big difference between dragging a slider vs dragging locator. –  Vitaliy Kaurov Jun 17 '12 at 15:37
Please see the update. –  Vitaliy Kaurov Jun 17 '12 at 19:34

• Cut off extra curve
• Labels A, B, C
• Show coordinates
• Enter coordinates manually (via yellow input field)

I think putting extra 2D "sliders" as you asked in comments will abuse interface and will be redundant, because your locators are basically a sort of 2D slider. So I interpreted your request as really asking for input fields.

Note you can easily remove showing coordinates next to A, B, C if it is too much.

catenary[x_] := a*Cosh[(x - c)/a] + y

m = Manipulate[
Module[{root}, (root =
FindRoot[
catenary[#[[1]]] == #[[2]] & /@ pt, {{y, 0}, {c, 0}, {a, 1}}];
Show[Plot[catenary[x] /. root, {x, pt[[1, 1]], pt[[2, 1]]},
AspectRatio -> 3/2],
Graphics[{{Red, Point[pt]},
Text[Style["A " <> ToString[pt[[1]]], "Subsection"], .2 + pt[[1]]],
Text[Style["B " <> ToString[pt[[2]]], "Subsection"], .2 + pt[[2]]],
Text[Style["C " <> ToString[pt[[3]]], "Subsection"], .2 + pt[[3]]]}],
PlotRange -> {{-3, 3}, {-3, 3}},
AspectRatio -> 1,
ImageSize -> 350])], {{pt, {{-1, 1}, {1, 1}, {0, 0}}},
Locator}, {{pt, {{-1, 1}, {1, 1}, {0, 0}}, ""}, InputField,
Background -> Lighter[Yellow], FrameMargins -> 3,
BaseStyle -> {"ControlStyle", 14}, ImageSize -> 360}]


-
I think so, and also with a text box for A,B,C where they can both see the current value and enter a value (if I read the question right) –  rm -rf Jun 17 '12 at 14:54
Yes perfect! You answered my 2nd question.. Do you have an idea for the first one? Because in this solution, it still like the other one, to modify the position of the point, you have to modify it just with the locator.. It is perfect with the locator, but is there a way, so that i can modify the position of the 3 points, with a dimmer (variator) too? I dont know how we call it, exactly but the typical thing that creates "Manipulate".. It appears normally above the curve, and you can variate the value of some variable in the function.. in our case it will be the x/y-coordinates of the 3 points –  Zellel B Jun 17 '12 at 14:56
exactly R.M :-) –  Zellel B Jun 17 '12 at 15:02
@ZellelB Could you answer the question I added ant the end of my answer? ;-) –  Vitaliy Kaurov Jun 17 '12 at 15:18
lol didnt seen it at the beginning.. sorry. Yeah a 2D-Slider! But i thought that slider is created with manipulate, and you can put (if you dont want to use the mouse) the value that you want to have, and the slider goes directly there.. thanks! –  Zellel B Jun 17 '12 at 15:26