How can I work with tables/lists of Locator
s under manipulate?
Note this is very similar to this question:
https://mathematica.stackexchange.com/a/51956/2079
The closest I've come is this:
n = 3
Manipulate[
Graphics[{Circle[{0, 0}], Line[{{0, 0}, a[1]}]}],
Sequence @@
Map[{{a[#], RandomReal[{-1, 1}, {2}]}, Locator} & ,
Range[n]] // Evaluate]
However any attempt to referece a
by a variable index fails:
n = 3
Manipulate[
Graphics[{Circle[{0, 0}], Map[Line[{{0, 0}, a[#]}] &, Range[n]]}],
Sequence @@
Map[{{a[#], RandomReal[{-1, 1}, {2}]}, Locator} & ,
Range[n]] // Evaluate]
"coordinate a[1] should be a pair of numbers.. "
My best attempt at following the approach in the linked answer also fails:
n = 3
Manipulate[
Graphics[Circle[{0, 0}]],
{{data, RandomReal[{0, 1}, {n, 2}]}, ControlType -> None},
Sequence @@
Map[{{Dynamic[data[[#]]], RandomReal[{-1, 1}, {2}]}, Locator} & ,
Range[n]] // Evaluate]
"Manipulate argument {{data[[1]],{-0.864708,0.897225}},Locator} does not have the correct form for a variable specification."
This came up working on this: https://mathematica.stackexchange.com/a/80099/2079 by the way.
Manipulate
expression. Second, you should consider whether a simpleLocatorPane
will be a better solution thanManipulate
expression as solution to your problem. $\endgroup${ pts , list_of_initial_points }, Locator}
, rather than a sequence of separate Locator calls{ { point1 ,init1} , Locator } ,{ { point2 ,init2} , Locator } ..
.. $\endgroup$