# Generate random point on the external surface of this complex geometry

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]


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

## 1 Answer

ReplacePart[Table[RandomReal[{-2.45, 2.45}], 3],
RandomChoice[Range[3]] -> RandomChoice[{-2.45, 2.45}]]


(*

{-2.45, -2.15682, 1.28829}

*)

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