3
$\begingroup$

How can I get a random point on just the curved edge of a cylinder?

c = Cylinder[{{0, 0, 0}, {0, 0, 2}}, 2];
RandomPoint[RegionBoundary[c], 50]

almost works, but also adds points to the top and bottom.

$\endgroup$
2
$\begingroup$

You could intersect the boundary of an elongated cylinder with a cuboid:

region = RegionIntersection[
    Cuboid[{-2,-2,0}, {2,2,2}],
    RegionBoundary @ Cylinder[{{0,0,-1},{0,0,3}},2]
];

This creates a region consisting of the curved boundary of a cylinder along the $z$-axis of radius 2 and length 2. Then, use RandomPoint to get your points:

pts = RandomPoint[region, 1000];

Visualization:

Graphics3D[Point[pts]]

enter image description here

You could also intersect the boundary of the desired cylinder with an elongated cylinder:

region = RegionIntersection[
    RegionBoundary @ Cylinder[{{0,0,-1}, {0,0,3}}, 2],
    RegionBoundary @ Cylinder[{{0,0,0}, {0,0,2}},2]
];
$\endgroup$
1
$\begingroup$
cylinderHeight = 5;
cylinderRadius = 4;
myTheta = RandomReal[{-Pi, Pi}];
myHeight = RandomReal[];
{cylinderRadius Cos[myTheta], cylinderRadius Sin[myTheta], cylinderHeight myHeight}
$\endgroup$
1
$\begingroup$
pr[r_, h_] := ParametricRegion[{r Cos[θ], r Sin[θ], z}, {{θ, 0, 2 π}, {z, 0, h}}];

Graphics3D[{Point[RandomPoint[pr[2, 1], 1000]], Opacity[.5, Yellow], 
  Cylinder[{{0, 0, 0}, {0, 0, 1}}, 2]}]

enter image description here

$\endgroup$

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.