How to choose random coordinate insdide shape

How to choose random coordinate inside shape?

Here’s a couple of approaches you could take:

  1. Determine the AABB of the shape.
  2. Choose a random point in the AABB.
  3. If the point is outside the shape discard the point. Go to 2.

Or

  1. Triangulate the shape.
  2. Choose a random triangle using a weighted choice using the area of each triangle as the weight.
  3. Choose a random point in the triangle.
1 Like