how would I create a Manipulate to draw a InfiniteLine between two Locator? The first Loactor should control the x/y of the first point together with the y of the second one. The second Locator should control x/y of the second point only.
In other words the first Locator should parallel shift the line in y, the second one change the slope.
This is what I tried so far (track the changes of first point y and update second point):
Manipulate[
Graphics[
If[p1[[2]] =!= old,
p2[[2]] += p1[[2]] - old;
old = p1[[2]];
];
InfiniteLine[{p1, p2}],
PlotRange -> 4 {{-1, 1}, {-1, 1}}
],
{{old, 0}, ControlType -> None},
{{p1, {0, 0}}, Locator},
{{p2, {2, 1}}, Locator}
]
This "works" somehow but only when just slowly dragging the first point, otherwise it gets garbled.
Any hints wellcome.
Hello I came up with a new trial.
Manipulate[
Graphics[{InfiniteLine[{pt[[1]], pt[[2]]}]}, PlotRange -> 2],
{{pt, {{-1, 0}, {1, 0}}}, Locator,
TrackingFunction -> (pt = {#[[1]], #[[2]] + #[[1]] - pt[[1]]}; &)}]
The Idea is to detect delta movement of the first point an add it to the second one to keep the slope constant when moving the first point, done via the TrackingFunction option. Delta "should be" calculated by subtracting the old value pt[1] from the actual value #[1] both of the first point.
Somehow this still does not work, the longer you drag the more error bulds up. While @kglr solution is running smooth I am still curious why ma attempt fails.