Consider that task of randomly placing a line segment of some length $L$ near a plane s.t. a point $p$ at the center of the line segment is at most a distance $H$ from the plane and intersections between the line segment and the plane are forbidden. Alternatively, consider the task of randomly placing the line segment in a box or sphere that is large enough to contain the line segment without intersection between the segment and the boundaries of the container.
What is a proper procedure for "randomly" placing the line segment in scenarios like those outlined above s.t. a placement operation constitutes a uniform random sampling of all legal configurations of the line segment? For example, it's not at all clear to me that procedures such as: (a) selecting two points a distance $L$ apart and testing for intersection, or (b) selecting one point for the center of the line segment that randomly generating $(r,\theta,\phi)$ values for the line segment's 3D orientation, then testing for intersection, are free from bias.
Does it depend on the exact container geometry, or is there a general solution? What about for cylinders of radius $r$?
Maybe to talk a bit more about what I'm after - if we had something like a monoatomic gas molecule diffusing in a box via a Brownian motion, we can say (to rough approximation) that the system is ergodic and that a uniformly chosen coordinate, with room to admit a sphere approximately as large as the atomic particle, represents a uniform random sampling of a possible position of the particle. Of course, we also have to assume some kind of "reachability" condition here, i.e. that the particle can diffuse from one point to any other point. How can we perform the same random sampling if we stretched the sphere out into a thin cylinder?