Poor/wrong sampling in 1D DiscretizeRegion of splines?
There is a workaround involving Rationalize
.
Jet0[pts0_: {{1, 0}, {1.8, 1.8}, {0, 2}}] :=
Module[{xu, yu, n, m, knots, fx, fy, pr, mesh, t, r},
pts=Rationalize[pts0,0.001];
{xu, yu} = Transpose[pts];
n = 2; m = Length[pts];
knots = {ConstantArray[0, n + 1], Range[m - n - 1]/(m - n),
ConstantArray[1, n + 1]} // Flatten;
fx[t_] =
xu.Table[BSplineBasis[{n, knots}, i - 1, t], {i, Length[pts]}];
fy[t_] =
yu.Table[BSplineBasis[{n, knots}, i - 1, t], {i, Length[pts]}];
pr = ParametricRegion[{{r fx[t], r fy[t]}, -1 <= t <= 1 &&
0 <= r <= 1}, {t, r}];
mesh = ToElementMesh[pr, "MaxBoundaryCellMeasure" -> 0.1];
mesh["Wireframe"]]
works as expected:
Jet0[{{1, 0}, {1.8, 1.8}, {0, 3}}]
DiscretizeRegion
will work in place of ToElementMesh
:
Jet0[pts_: {{1, 0}, {1.8, 1.8}, {0, 2}}] :=
Module[{xu, yu, n, m, knots, fx, fy, pr, t, r},
{xu, yu} = Transpose[pts];
n = 2; m = Length[pts];
knots = {ConstantArray[0, n + 1], Range[m - n - 1]/(m - n),
ConstantArray[1, n + 1]} // Flatten;
fx[t_] = xu.Table[BSplineBasis[{n, knots}, i - 1, t], {i, Length[pts]}];
fy[t_] = yu.Table[BSplineBasis[{n, knots}, i - 1, t], {i, Length[pts]}];
pr = ParametricRegion[{{r fx[t], r fy[t]}, 0 <= t <= 1 && 0 <= r <= 1},
{t, r}];
DiscretizeRegion[pr, MaxCellMeasure -> {"Length" -> 0.1}]]
Jet0[{{1, 0}, {1.8, 1.8}, {0, 3}}]