Sample random positions on and in mesh

Hi all,

I would like to get random positions from the surface of an arbitrary mesh and as second step positions within an arbitrary mesh. I would like to move an object on the surface on another object randomly and therefore need that information. Does anybody know, if there is an easy way to get that information?

Thank you very much!

You are looking for barycentric coordinates. You can use Bmesh to get triangles and use barycentric coords to pick random points inside a polygon.

Depending on what you want to do kd trees and bvh trees might be useful.