Posted 26 October 2013 - 07:09 AM
In both cases, I would pick the height first and then pick a point in the slice at that height.
If you want a point in the frustum, pick a number v between 0 and the volume of the frustum (Pi*(R2^2*+R1*R2+R1^2)*h/3, I believe). You then need to find the height z at which the volume below z is v; you can do that by using the formula for the volume above, where z plays the role of h and one of the radii is linked to it by a simple relationship, and then solving for z. You then pick a random point in the disk at height z (this should be easy to find).
If you want a point on the frustum, I assume you need to generate a random point on the curvy side of the truncated cone. For that, you reason similarly but picking a random breakpoint for area, not volume. You then pick a random point on the circle at the desired height, which is trivial. If you need to generate points on the limiting disks as well, roll a die at the beginning to pick which of the three pieces the point will come from (of course the probability of each piece should be proportional to its area).