1
$\begingroup$

Suppose I have some small set of points Pts in 3D space:

Pts = Point[#] & /@ {{RandomReal[], RandomReal[], 
     RandomReal[]}, {RandomReal[], RandomReal[], RandomReal[]}};

Then, I apply Translate[] to make more points, for instance:

translatedPoints = Graphics3D@Translate[Pts, Tuples[Range[4], 3]]

enter image description here

The question is, how do I get the coordinates of the new set of points from the translatedPoints object? (as a list of points {{$x1, y1, z1$},..,{$xn, yn, zn$}})

Thanks!

$\endgroup$
1
  • 1
    $\begingroup$ use Point[Join @@ (TranslationTransform[#][First /@ Pts] & /@ Tuples[Range[4], 3])] instead of Translate[Pts, Tuples[Range[4], 3]? $\endgroup$
    – kglr
    May 3, 2020 at 4:53

1 Answer 1

4
$\begingroup$

1. With a slightly different way to use Translate we can use Normal on translated points:

translatedPoints2 = Graphics3D[Translate[Pts, #] & /@ Tuples[Range[4], 3]]; 

translatedPoints2[[1]] // Short[#, 10] &

enter image description here

tpts = Join @@ Normal[translatedPoints2[[1]]];

tpts[[All, 1]] // Short[#, 15] &

enter image description here

2. Alternatively, you can post-process your translatedPoints before using Normal to get the same result:

tpts == Join @@ Normal[translatedPoints[[1]] /. 
   Translate[a_, tr_] :> (Translate[a, #] & /@ tr) ] 
 True

3. Post-process your translatedPoints using TranslationTransform:

tpts[[All, 1]] == 
 Join @@ (translatedPoints[[1]] /. 
    Translate[a_, tr_] :> (TranslationTransform[#][First /@ a] & /@ tr))
 True
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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