Evenly-space point grid in Grasshopper


I created a matrix of points constrained within a rectangle drawn in rhino. I want the U and V divisions to have a relationship to the aspect ratio of the rectangle, so that the points looks evenly distributed.

However, depending on how a curve is drawn in Rhino, the U and V directions can change, and do not bear a relationship to the X and Y directions in Rhino. I think the solution is quite simple, but I can’t find it

Any thoughts? Screenshots and files attached.

U-V swap curves.3dm (176.5 KB)
u-v swap.gh (9.5 KB)

I realized the problem is that the U and V direction is a count that only accepts integers…so when my aspect ratio produces anything other than an integer, the U input rounds the number.

Any ideas on how to get equal spacing between each row and column? I don’t care if the points run off the edge of the curve a bit. I have posted my whole script so you all can understand the context of what I’m trying to achieve.

U-V swap curves.3dm (176.8 KB) u-v problem.gh (19.2 KB)