4
$\begingroup$

enter image description here

I'm working through a coding exercise to program a matrix of Lissajour Curves in Mathematica but have encountered an obstacle when trying to recover the translated Point to then do further processing on them (as seen through the link). I've encountered problems trying to recovering the updated coordinates of translated points using Normal before. In this case I've gone so far as to try to rebuild that solution in my current notebook to no avail. It seems like there should be some application of Normal to Graphics[graphicsdata] that would generate the updated point coordinates in a list. I'm not sure what I'm missing about how Normal works but it would be useful to understand it as I try to advance my Mathematica program complexity.

angle = Drop[Range[0,Pi 2,(2 Pi)/20],-1];
cols = 5;
rows = 3;
radius = .45;

functionXY[anglevar_]:= {radius * Cos[anglevar],radius * Sin[anglevar]}

translatevectors = Flatten[{Table[{x,0},{x,cols}],Table[{0,-y},{y,rows}]},1];
points = Point /@ functionXY /@ angle;
graphicsdata = Table[Translate[#, translatevectors[[n]]] &/@ points,{n,Length@translatevectors}];
Graphics[graphicsdata]

Updated Dec 29 2018

I just thought it would be helpful to post the updated code here using the suggestions below should others find themselves in the postion of Normal not recovering translated coordinates as expected. In this case it is probably better to use TranslationTransform in the first place as now graphicsdata returns exactly the updated point's new coordinates that can be further post-processed.

elementaryPoints = functionXY /@ angle;
graphicsdata = Table[TranslationTransform[translatevectors[[n]]]@# &/@ elementaryPoints,{n,Length@translatevectors}];
Table[Point /@ graphicsdata[[n]],{n, Length@translatevectors}] // Graphics

enter image description here

$\endgroup$
3
  • $\begingroup$ maybe normal = # /. Translate[(prim : Alternatives[Point, Line, Circle])[x_, y___], t_] :> prim[TranslationTransform[t]@x, y] &; normal@Graphics[graphicsdata]? ` $\endgroup$
    – kglr
    Dec 29 '18 at 3:39
  • $\begingroup$ I'm new to being able to close questions with one vote, so if you think this shouldn't be closed, just let me know. $\endgroup$
    – Carl Woll
    Dec 29 '18 at 21:27
  • $\begingroup$ I'd suggest not closing it. I rarely see the overlap and it has two votes now anyways. $\endgroup$
    – BBirdsell
    Dec 30 '18 at 1:51
3
$\begingroup$

As mentioned in the linked q/a, the section Properties and Relations in Scale, Translate and GeometricTransformation says:

When possible, Normal will transform the coordinates explicitly.

When Normal does not work, you can post-process the translated primitives to regular primitives with translated coordinates:

normal = # /. Translate[Point[x_], t_] :> Point[TranslationTransform[t]@x] &;
coords = Cases[normal@Graphics[graphicsdata], Point[x_] :> x, ∞];

Show[ListPlot[coords, AspectRatio -> Automatic, Axes -> False, 
  PlotStyle -> Directive[AbsolutePointSize[7], Opacity[.7, Red]]], 
 Graphics[graphicsdata]]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks; that all checks out wonderfully. I, of course, read that in the docs, but was puzzled as to what the exact conditions were when it is possible. Perhaps I should be rewriting this part of the code to use TranslationTransform instead of Translate? $\endgroup$
    – BBirdsell
    Dec 29 '18 at 16:47

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