Skip to main content
added 511 characters in body
Source Link
LLlAMnYP
  • 11.6k
  • 28
  • 68

I hate fiddly held expressions! But I managed to get this Dynamic construct to work.

n = 4; left[x_, y_, z__] := Abs@Product[x + I y - Complex @@ zz, {zz, {z}}] right[z__] := Abs@Product[Complex @@ zz, {zz, {z}}] DynamicModule[{z = RandomReal[{-5, 5}, {n, 2}]}, Dynamic[Show[ ContourPlot[ left[x, y, Sequence @@ z] == right[Sequence @@ z], {x, -15, 15}, {y, -15, 15}, ImageSize -> Large], Graphics[ Evaluate@Table[With[{i = i}, Locator[Dynamic[z[[i]]]]], {i, n}] ]]] ] 

Dynamic levels

I'm not sure of the best way to limit the locators to within the unit circle... in fact I hardly understand my own code :-)

But at least you now have an easy way to set up an arbitrary number of poles.

Update

On Mathematica v8 dragging one locator drags them all together. Don't know why. The requested feature in the comments requires the following replacement: change the Graphics[...] to

Graphics[(Evaluate@ Table[With[{i = i}, Line[{{0, 0}, z[[i]]}]], {i, n}])~Join~ (Evaluate@ Table[With[{i = i}, Locator[Dynamic[z[[i]]]]], {i, n}]) ] 

Works as normal on my machine with M.v.10

Lines

I hate fiddly held expressions! But I managed to get this Dynamic construct to work.

n = 4; left[x_, y_, z__] := Abs@Product[x + I y - Complex @@ zz, {zz, {z}}] right[z__] := Abs@Product[Complex @@ zz, {zz, {z}}] DynamicModule[{z = RandomReal[{-5, 5}, {n, 2}]}, Dynamic[Show[ ContourPlot[ left[x, y, Sequence @@ z] == right[Sequence @@ z], {x, -15, 15}, {y, -15, 15}, ImageSize -> Large], Graphics[ Evaluate@Table[With[{i = i}, Locator[Dynamic[z[[i]]]]], {i, n}] ]]] ] 

Dynamic levels

I'm not sure of the best way to limit the locators to within the unit circle... in fact I hardly understand my own code :-)

But at least you now have an easy way to set up an arbitrary number of poles.

I hate fiddly held expressions! But I managed to get this Dynamic construct to work.

n = 4; left[x_, y_, z__] := Abs@Product[x + I y - Complex @@ zz, {zz, {z}}] right[z__] := Abs@Product[Complex @@ zz, {zz, {z}}] DynamicModule[{z = RandomReal[{-5, 5}, {n, 2}]}, Dynamic[Show[ ContourPlot[ left[x, y, Sequence @@ z] == right[Sequence @@ z], {x, -15, 15}, {y, -15, 15}, ImageSize -> Large], Graphics[ Evaluate@Table[With[{i = i}, Locator[Dynamic[z[[i]]]]], {i, n}] ]]] ] 

Dynamic levels

I'm not sure of the best way to limit the locators to within the unit circle... in fact I hardly understand my own code :-)

But at least you now have an easy way to set up an arbitrary number of poles.

Update

On Mathematica v8 dragging one locator drags them all together. Don't know why. The requested feature in the comments requires the following replacement: change the Graphics[...] to

Graphics[(Evaluate@ Table[With[{i = i}, Line[{{0, 0}, z[[i]]}]], {i, n}])~Join~ (Evaluate@ Table[With[{i = i}, Locator[Dynamic[z[[i]]]]], {i, n}]) ] 

Works as normal on my machine with M.v.10

Lines

Source Link
LLlAMnYP
  • 11.6k
  • 28
  • 68

I hate fiddly held expressions! But I managed to get this Dynamic construct to work.

n = 4; left[x_, y_, z__] := Abs@Product[x + I y - Complex @@ zz, {zz, {z}}] right[z__] := Abs@Product[Complex @@ zz, {zz, {z}}] DynamicModule[{z = RandomReal[{-5, 5}, {n, 2}]}, Dynamic[Show[ ContourPlot[ left[x, y, Sequence @@ z] == right[Sequence @@ z], {x, -15, 15}, {y, -15, 15}, ImageSize -> Large], Graphics[ Evaluate@Table[With[{i = i}, Locator[Dynamic[z[[i]]]]], {i, n}] ]]] ] 

Dynamic levels

I'm not sure of the best way to limit the locators to within the unit circle... in fact I hardly understand my own code :-)

But at least you now have an easy way to set up an arbitrary number of poles.