3
$\begingroup$

I have a start photo (StartShot) with 0-400, 0-400 coordinates:

enter image description here

And this path:

In[27]:= newpaths = Accumulate[Join[startingpoints, dxy]]
Out[27]= {{377.025, 272.122}, {373.537, 322.001}, {326.261, 
  305.722}, {319.303, 256.209}, {362.161, 230.457}, {411.788, 
  236.55}, {417.015, 286.276}, {392.015, 329.578}, {385.056, 
  379.091}, {374.661, 330.184}, {422.957, 343.125}, {375.681, 
  359.403}, {395.218, 405.428}, {443.033, 420.047}, {418.792, 
  463.778}, {467.307, 451.682}, {420.948, 432.951}, {470.332, 
  440.773}, {430.932, 409.99}, {390.481, 380.601}, {433.782, 355.601}}

enter image description here

Then I would like to clip it into 400 x 400 sub-parts, from the origo (0,0):

worldsize=400;
lineplot1 = 
  ListLinePlot[newpaths, AspectRatio -> 1, Axes -> None, 
   Frame -> False, PlotStyle -> Blue, 
   PlotRange -> {{0, worldsize}, {0, worldsize}}];
lineplot2 = 
  ListLinePlot[newpaths, AspectRatio -> 1, Axes -> None, 
   Frame -> False, PlotStyle -> Blue, 
   PlotRange -> {{ worldsize, 2 worldsize}, { 0, worldsize}}];
lineplot3 = 
 ListLinePlot[newpaths, AspectRatio -> 1, Axes -> None, 
  Frame -> False, PlotStyle -> Blue, 
  PlotRange -> {{ worldsize, 2 worldsize}, { worldsize, 2 worldsize}}]
lineplot4 = 
  ListLinePlot[newpaths, AspectRatio -> 1, Axes -> None, 
   Frame -> False, PlotStyle -> Blue, 
   PlotRange -> {{0, worldsize}, { worldsize, 2 worldsize}}];

Then I merge them:

fullworld = 
 ImageCompose[StartShot, {lineplot1, lineplot2, lineplot3, lineplot4}]

enter image description here

Is any way to simplify this kind of task? Cutting the plot into sub-parts, and merge them? For example automate the creation of lineplots.

$\endgroup$
  • $\begingroup$ Probably you edit your question to clarify what are the specifications of the end result you need. Is it related to ImagePartition ? $\endgroup$ – rhermans Jan 11 '16 at 14:54
2
$\begingroup$
ImageCompose[StartShot, ListLinePlot[newpaths, AspectRatio -> 1, Axes -> None, 
    PlotStyle -> Blue, PlotRange -> #] & /@ 
    Flatten[Table[{{i - 1, i}, {j - 1, j}}, {i, 2}, {j, 2}] worldsize, 1]]

gives the desired image.

enter image description here

Addendum

If, as suggested by the OP in a comment below, the random walk proceeds beyond 2 worldsize in either dimension, the ListLinePlot must be broken into more segments, which can be done as follows.

Ceiling[Max[#]/worldsize] & /@ Transpose[newpaths];
ImageCompose[StartShot, ListLinePlot[newpaths, AspectRatio -> 1, Axes -> None, 
    PlotStyle -> Blue, PlotRange -> #] & /@ 
    Flatten[Table[{{i - 1, i}, {j - 1, j} }, {i, First@%}, {j, Last@%}] worldsize, 1]]

For instance, if {833.782, 155.601}, {133.782, 955.601} is appended to the end of newpaths, the figure becomes

enter image description here

Note that the coordinates of each point in newpaths are assumed not to become negative. If one or both do, the lower bounds on i and j, now equal to 1, also must be modified. An expression of the sort

Floor[Min[#]/worldsize] & /@ Transpose[newpaths];

would suffice.

$\endgroup$
  • $\begingroup$ That's what I needed I will accept it. I only miss a little modification for define 'i' and 'j' from the path coordinates and the world size (400). For example the random walk can get a coordinate (940,100), then I must pick two plot from the right side. Many thanks! $\endgroup$ – pnz Jan 11 '16 at 17:56
  • $\begingroup$ @pnz1337 I do not understand what is meant by "pick two plot from the right side". Please explain. $\endgroup$ – bbgodfrey Jan 12 '16 at 2:12
  • $\begingroup$ So the plot is a periodic (like a torus world in 2d), thus a random walk can wander too far from the starting point. Its origin is in the starting domain: bottom-left coordinate (0,0), top-right coordinate (400,400). But the walk can go out from the boundaries, for example to a coordinate (940,100), and then I need all of those (400x400) size windows, which the move crossed. So the second window from the right must be clip for sure. So the 'paths' has to be analysed to define the clipper windows. $\endgroup$ – pnz Jan 12 '16 at 10:41
  • $\begingroup$ Many thanks again ! $\endgroup$ – pnz Jan 12 '16 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.