0
$\begingroup$

This is a followup to this question of mine.

How do I generate a random point on the most external surface of this complex geometry?

pts = {{-0.5, -0.5, -0.5}, {-0.5, 0.5, -0.5}, {-0.5, 0.5, 
    0.5}, {-0.5, -0.5, 0.5}, {0.5, -0.5, -0.5}, {0.5, 
    0.5, -0.5}, {0.5, 0.5, 0.5}, {0.5, -0.5, 0.5}};
pts1 = ScalingTransform[{4.6, 4.6, 4.6}][pts]; pts2 = 
 ScalingTransform[{4.9, 4.9, 4.9}][pts];
pts3 = ScalingTransform[{4.903, 4.903, 4.903}][pts];
hex = {{2, 3, 4, 1}, {1, 4, 8, 5}, {4, 3, 7, 8}, {3, 2, 6, 7}, {2, 1, 
    5, 6}, {5, 8, 7, 6}};
r1 = BoundaryMeshRegion[Join[pts1], Polygon[hex], 
   MeshCellStyle -> Opacity[0.2]];
r2 = BoundaryMeshRegion[Join[pts2, pts3], Polygon[hex], 
   Polygon[hex + 8], MeshCellStyle -> Opacity[0.2]];

Show[r1, r2]

enter image description here

Please remember I use version 10, where RandomPoint is not available

$\endgroup$
0
$\begingroup$
ReplacePart[Table[RandomReal[{-2.45, 2.45}], 3], 
 RandomChoice[Range[3]] -> RandomChoice[{-2.45, 2.45}]]

(*

{-2.45, -2.15682, 1.28829}

*)

$\endgroup$
  • $\begingroup$ I get the error: argument 3 at position 2 does not have the correct form for an iterator. $\endgroup$ – mattiav27 Aug 14 '18 at 8:24
  • $\begingroup$ Solved! In version 10 you need: {3} in Table. $\endgroup$ – mattiav27 Aug 14 '18 at 11:12

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.