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 InterpolatingFunction
s. How can I fill the space between two BezierCurve
s or InterpolatingFunction
s?
For example, I have the BezierCurve
s 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[[1]]}, 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?