I have been able to implement point picking for cylinders and spheres. However, I struggle to implement a solution for a cuboid.
Please see code for point generation on cylinders and spheres below:
Cylinder:
Point[Table[{radius*Cos[#1], radius*Sin[#1], #2} &[
RandomReal[{0, 2 Pi}], RandomReal[{p1[[3]], p2[[3]]}]], {expNo}]];
Sphere:
Point[Table[{Cos[#1] Sqrt[1 - #2^2], Sin[#1] Sqrt[1 - #2^2], #2} &[
RandomReal[{0, 2 Pi}], RandomReal[{-radius, radius}]], {expNo}]];
In both cases {expNo}
denotes a number of points;
How could I do the same for a Cube?
I consulted MathWorld on how to do this, but I was unsuccessful in implementation.
RandomChoice[]
for picking any of the six faces, using the area of each face as the weight (thus,RandomChoice[{area1, area2, …} -> {1, 2, …}]
). Having picked a face in this manner, use your method of picking points in a rectangle. $\endgroup$Append[Normalize[RandomVariate[NormalDistribution[], 2]], RandomReal[]]
andNormalize[RandomVariate[NormalDistribution[], 3]]
. $\endgroup$