I have a list of 2D points which I partition every time the distance between consecutive list elements is bigger than a certain threshold. In a second step I select all the lists that start within a radius of 1 from the origin.
Any ideas to improve my current code?
Generate some test data:
data = Flatten[
Table[Table[
Table[a + s RotationMatrix[b].{0, 1}, {s, 0, 10, 0.1}], {b,
RandomReal[2 Pi, 5]}], {a, {{0, .1}, {1, 2}, {0.4, 0.2}, {1,
1}, {-2, 1}}}], 2];
ListPlot@Partition[data, 101]
Partition the data:
sepL = Most[0.2 > Norm[#1 - #2] & @@@ Transpose[{data, RotateLeft@data}]];
parts = Partition[Flatten@{1, 1 + Accumulate[Length@# & /@ Split[sepL]]}, 2];
res = Select[data[[#1 ;; #2]] & @@@ parts, Norm[#[[1]]] < 1 &];
ListPlot@res