I am following this topic in order to get my resuls. This code should be quite general but I get a really basic error which I don’t understand how…
So my code is:
bezier[pts_List] :=
With[{n = Length[pts] - 1},
Evaluate@Sum[
Binomial[n, i] (1 - #)^(n - i) #^i pts[[i + 1]], {i, 0, n}] &]
yfn[pts_] :=
Piecewise[
Function[pp,
Select[y /.
N@Solve[Rationalize[
bezier[pp][t] == {x, y} && pp[[1, 1]] <= x <= pp[[-1, 1]],
0], {y}, {t}, Reals, Method -> Reduce] /.
Less -> LessEqual // Expand,
Chop[# - pp[[1, 2]] /. x -> pp[[1, 1]]] == 0 &] /.
ConditionalExpression ->
Sequence] /@ (If[Length@Last@# == 1, Most@#, #] &@
Partition[pts, 4, 3, 1, {}]), Indeterminate]
and
btm = {{100., -0.0039549}, {1250/
13, -0.465743}, {91.9629, -0.627156}, {87.7691, -0.725599}, \
{83.5791, -0.908002}, {79.3881, -1.06942}, {75.198, -1.25182}, \
{71.0079, -1.43422}, {66.8206, -1.67959}, {62.6305, -1.862}, \
{58.4423, -2.08638}, {54.2522, -2.26878}, {50.0621, -2.45119}, \
{45.8721, -2.63359}, {41.6802, -2.77401}, {37.491, -2.97741}, {33.3, \
-3.13882}, {29.1099, -3.32122}, {24.9208, -3.52462}, {20.7298, \
-3.68603}, {18.6366, -3.81921}, {16.5415, -3.91041}, {14.4465, \
-4.00161}, {12.3506, -4.07183}, {10.2492, -4.0161}, {8.14138, \
-3.81344}, {7.12596, -3.62981}, {6.02085, -3.31691}, {5.10096, \
-2.97019}, {3.88485, -2.46356}, {2.86923, -1.98654}, {1.73975, \
-1.40031}, {0.721154, -0.6}, {0.238654, -0.231058}, {0.00972115, \
-0.0211058}, {0, -0.00396087}}
What I would like to get is yfn[btm] but I get an error saying Nonatomic expression expected at position 1 in Select[y,Chop[#1-Part[<<3>>]/. x->{<<4>>}[[1,1]]]==0&]. >>
I don’t know why this happens nor do I know how to get rid of that error. Please help.