I am trying to find an intersection between a straight line and a BSpline.
The lines:
Manipulate[pts = {p0, p1, p2, {3, 1}};
c = BSplineFunction[pts];
d[x_?NumericQ] := c[x][[1]];
e[x_?NumericQ] := c[x][[2]];
tang = c[.22999] - c[.23001];
tanline = {c[.23] + tang*10000, c[.23] - tang*10000};
pline = {c[.23] + {-tang[[2]]*10000, tang[[1]]*10000},
c[.23] - {-tang[[2]]*10000, tang[[1]]*10000}};
Graphics[{BezierCurve[pts], Point[c[.23]],
Line[tanline], {Blue, Line[pline]}, {Red, Line[{{4, -4}, l1}]}},
PlotRange -> 4], {{p2, {2, 3}}, Locator}, {{p1, {2, 4}},
Locator}, {{p0, {1, 1}}, Locator}, {{l1, {1, 1}}, Locator}]
(The tangent lines are part of the larger problem I'm trying to solve, not strictly related to the intersection problem)
I have read various threads for getting symbolic functions to evaluate numerically, but none of the solutions they've used seem to work.
I've been testing functions using the starting red line, with eq -1.666 x + 2.666
FindRoot[-1.66*d[x] + 2.666 == e[x], {x, .8}]
and
FindRoot[-1.66*N[d[x]][[1]] + 2.667 == d[x][[2]], {x, 2}]
And various other things that also failed similarly. Short of implementing the numerical solve myself, what can I do? Am I misusing NumericQ?
BernsteinBasis[]orBSplineBasis[](you had me confused because you were using B-splines in one part and Béziers in another). See e.g. this thread. – J. M.'s missing motivation Jun 30 '16 at 07:53dandeoutside of yourManipulateexpression, or they will be continuously re-evaluated. – MarcoB Jun 30 '16 at 14:16