# Fill space between two BezierCurves with random points

I asked a question about filling the space between two curves (Sin and Cos) with random points and the answer I received does not work for InterpolatingFunctions. How can I fill the space between two BezierCurves or InterpolatingFunctions?

For example, I have the BezierCurves c1 and c2:

c1 = {{0, 0}, {2, 0}, {2, 1}};
c2 = {{0, 0.25}, {1.75, 0.25}, {1.75, 1}};

Graphics[{BezierCurve@c1,BezierCurve@c2}]


I can use RandomPoint by turning these curves into a Polygon:

f[c_] := Quiet@
Interpolation[BezierFunction[c][#] & /@ Range[0, 1, 0.01]];
g[c_] := {#, f[c][#]} & /@ Range[0, c[[-1, 1]], 0.01];

h1 = Join[{c2[]}, g@c1]; h2 = Join[g@c2, {c1[[-1]]}];

Graphics[{
Point@RandomPoint[Polygon@Join[h1, h2], 500],
Thick, Line@h1, Line@h2
}] My question is, is there a better/more efficient way of doing this?

• To people trying to solve this: here is a possible pitfall to be aware of. – J. M. will be back soon Apr 21 '17 at 16:03

you can do it with sorcery...

c1 = {{2, 1}, {2, 0}, {0, 0}};
c2 = {{0, 0.25}, {1.75, 0.25}, {1.75, 1}};
gk = JoinedCurve[{Line[{{0, 0}, {0, 0.25}}], BezierCurve@c2,
Line[{{1.75, 1}, {2, 1}}], BezierCurve@c1}];
Graphics[{Black,
FilledCurve[{BezierCurve@c1, Line[{{0, 0}, {0, 0.25}}],
BezierCurve@c2, Line[{{1.75, 1}, {2, 1}}]}], White,
Point[RandomPoint[Disk[{1, 0.45}, {1.3, 0.9}], 5000]]}] 