I'm trying to implement a complicated Manipulate[] interface. I'm not really interested in working code, but for those interested, I would like the program to
- allow you to drag around a variable number of locators,
- and have it output the motion of an object traveling from one locator to the next in straight line segments at constant velocity (just the function of time; no actual animation needed), and graph of the motion (i.e. connect the locators on the screen via ParametricPlot[]).
- One last thing: the times at which the object passes each of the locators are needed to specify a unique solution. But rather than manipulating the times themselves, I'd like to have input fields for the average velocity in each segment, and have the program infer the times.
Here is a schematic that describes how I've tried to accomplish this:
However, I have been stumped as to how to implement this. Manipulate[] doesn't seem to have enough flexibility, and Dynamic[] seems to come with its own issues. All I'd like to know is if this is a dead end, or if not, some rough outline of how I could complete this implementation. Here is how far I've gotten, with the help of a few answered stack exchange questions:
GLOBAL PARAMETERS:
Row[{SetterBar[Dynamic@\[CapitalNu], Range[1, 10, 1]]," Sets Length of X,Y,V"}]
INTERFACE VARIABLES -> INTERNAL VARIABLES:
Internalize[{V_, {X_, Y_}}, N_] := Module[{T},
T = Table[0, {i, 1, N + 2}];
For[i = 2, i <= N + 2, i++,
T[[i]] =
T[[i - 1]] + Norm[{X[[i - 1]], Y[[i - 1]]} - {X[[i]], Y[[i]]}]/
V[[i]];];
T
]
X := Table[
ToExpression["x" <> ToString@i], {i, 0, \[CapitalNu] + 1}];
Y := Table[
ToExpression["y" <> ToString@i], {i, 0, \[CapitalNu] + 1}];
V := Table[
ToExpression["v" <> ToString@i], {i, 1, \[CapitalNu] + 1}];
T := Internalize[{V, {X, Y}}, \[CapitalNu]];
MANIPULATE INTERFACE
Procedure[T_,{X_,Y_}]:= Piecewise@
position=Table[{{X[[i]]-(t-T[[i]])/(T[[i+1]]-T[[i]]))(X[[i]]-X[[i-1]]),Y[[i]]-(t-T[[i]])/(T[[i+1]]-T[[i]]))(Y[[i]]-Y[[i-1]])},
T[[i]] <= t <= T[[i + 1]]}, {i, 1, \[CapitalNu]}]
(*The rest would look like this:
Manipulate[ParametricPlot[Procedure[Dynamic@T,{Dynamic@X,Dynamic@Y}][t], {t,T[[1]],T[[-1]]}],
Table[{X[[i]],Y[[i]]},Locators],Table[Silders[V[[i]]]]],] *)
Does anyone know if Mathematica is capable of something like this? (I must emphasize, the Manipulate interface has to adjust automatically to changes in N; no retyping code permitted).
The key issue I haven't been able to figure out is how to apply Manipulate[] controls, including locators, to the elements of variable length lists.
While this question may seem unnecessarily long, context really helps.
Locator
refer to this. There's only one mention of locator in your code but it wasLocators
, which I think is a typo. If so, what do you want these locators to do? $\endgroup$time-wise parametrized piece-wise
sounds very intimidating to me. Perhaps you might want to explain a little broader what you're trying to do. Are you tracking an object? If so, what information are you given about this object (position, speed, etc.)? Just dumb it down a little i.e. use less jargon, so that the readers can understand what you're trying to do. $\endgroup$