# Interacting Dynamic Components within LocatorPane

I am attempting to create a dynamic contour plot of an ellipse with two locators as the foci within a locator pane. The following code has been implemented:

a:= Sqrt[c^2 + b^2]
b = 1;
c = 0;

ellipse := (x^2)/(a^2) + (y^2)/(b^2)
plot := Dynamic[ContourPlot[ellipse == 1, {x,-2,2}, {y,-2,2}]

LocatorPane[Dynamic[{ {c,0}, {-c,0} }], plot]


When I evaluate this, the plot behaves pretty much as desired except that only one of the locators can be moved.

This is because I placed -c inside Dynamic as opposed to just the variable c. Ordinarily, I would just do something like Dynamic[{-c,0}, (c = -#)&], however, LocatorPane requires that I include the full list of locators within a single Dynamic.

I want to find a way to apply a function to Dynamic that causes the first component of the second locator to take on the value of -c while the first locator is using c.

Any help?

• Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Dr. belisarius Feb 19 '15 at 14:50

b = 1;
ellipse[x_, y_, pt_] := (x^2)/(pt[]^2 + b^2) + (y^2)/(b^2)
DynamicModule[{pt = {0, 0}},
LocatorPane[Dynamic[pt],
Dynamic@ContourPlot[ellipse[x, y, pt] == 1, {x, -2, 2}, {y, -2, 2},
Epilog -> {PointSize[Large], Point[Dynamic[{First[pt], 0}]],
Point[Dynamic[{-First[pt], 0}]]}], Appearance -> None]] • Clean! +1. Btw. why Epilog needs Dynamic@Locator in: x = {0, 0}; { Graphics[{Locator@Dynamic@x}], Graphics[{}, Epilog -> {Locator@Dynamic@x}], Dynamic[x] } – Kuba Feb 19 '15 at 15:19
• @Kuba Thanks:)! You need the Dynamic[] to update and the Locator[] to know what to display. You may change the Locator[] by Point[], for example. – Dr. belisarius Feb 19 '15 at 15:23
• @Kuba Oh, I see now. Not sure, let me think (or post a question!) – Dr. belisarius Feb 19 '15 at 16:18
• @Kuba There was a question about "how deep" Dynamic "sees" when it acts on a expression. I believe it is related to that – Dr. belisarius Feb 19 '15 at 16:24
• @belisarius any idea which one? :) – Kuba Feb 20 '15 at 10:29