Ok, slight addition to this question. Looking in the docs, I see that when you use the eval function on a polygon, it ignores the v component. And from what I can tell, when you pass the u component, it spits back out positions that are only on the edges of the polygon.
I’m looking for a way to get a random position within the polygon. My hacky solution is to look up 2 different random positions along the edges, and average them together. It’s not great, but it kinda works.
However, is there any python function that will give a random position within a polygon?
Let’s assume for simplicity that the polygon is flat and convex.
You might consider converting 4 point polygons into 2x2 grids.
3 point polygons, could be 2x2 grids with coincident points.
Not sure a fast way of doing this with native SOPs, but you could Script SOP it.
For higher vertex counts, you can use Divide SOP, with Convex option to get them down in count.
I’m not sure if I follow how turning the polygons into 2x2 grids would help with finding a random point on it’s surface. Are you still referring to using the prims.eval method in a Script SOP?
What kind of geo is the prims.evals function expecting? Because when I pass it a single 4 point polygon, I only get values returned on the edges, not within the area of the polygon.
Also, only the ‘u’ value seems to have any effect. Changing the ‘v’ doesn’t seem to do anything.
The example I attached in the first post should demonstrate that. Although it’s always possible that I missed something simple.