Code:
(*Cylinder Point Picking*)
ppCylinder[p1_List, p2_List, radius_Integer, expNo_Integer] :=
Module[
{pts},
(*Set point coordinates *)
pts := Point[Table[{radius*Cos[#1], radius*Sin[#1], #2} &[RandomReal[{0, 2 Pi}], RandomReal[{p1[[3]], p2[[3]]}]], {expNo}]];
(*Visualize*)
Graphics3D[{Cylinder[{p1, p2}, radius], pts}, Boxed -> False]
];
(*Test*)
ppCylinder[{0, 0, 0}, {0, 0, 1}, 2, 5000] (*Output #1*)
ppCylinder[{0, 0, 0}, {0, 1, 2}, 2, 5000] (*Output #2*)
Based on the code I wrote, I am satisfied with the output 1# but not #2. How could I modify the existing code to account for {X && Y} variation when generating a set of random points on a cylinder surface?




p1andp2to generate the points. – Jason B. Oct 26 '15 at 12:27