# Generate random points (vector) inside an irregular shaped object

I have an image of a human and want to generate random points inside this image.
I would appreciate if someone comes up with a more general solution i.e. for an irregular 3d shaped object

so a not so optimal solution, but one that would work, is to find the rectangular bounds of your polygon and generate a random point within that. you can then use an algorithm such as this to determine whether or not that point is inside the polygon. this is suboptimal for several reasons, the most obvious being that its theoretically possible to generate many points that arenâ€™t inside the polygon and therefor to do the same operations for a long time.

Another approachable but convoluted solution that I can think of that would WORK but not necessarily be purely random would be to pick 2 random line segments making up 2 of the sides, then pick a random point on each of the lines, then draw a line between them. then you would pick a random point along that line. the problem there is you would need to calculate if that new line ever left the shape (which is very possible if your polygon is concave) and then to omit any sections of that line that fall outside the polygon from being randmly selected.

finally theres the pureblooded maths if you arent too afraid of that. you can use triangle point picking to subdivide the polygon into a more approachable shape before picking a random point. you could also use an approach like this if your polygon is has regular sides. There are surely other algorithms if you google around a little bit.