I'm trying to calculate the intersection point of a curve given by a parametric equation and a vector. (i.e. a circle and a ray vector bouncing within the circle).
So far I couldn't find an efficient way to calculate the intersection points of the vector and the curve. I tried "FindRoot", "Solve", "Reduce" etc. but all have their own drawbacks. (e.g. The problem with FindRoot was that I could not find an easy way to generate a good starting point for the parameter t. But without it, the obvious solution with a vector of length 0 at r[t0] was returned...)
A general problem of my other solutions is, that they are all extremely slow.
For further processing I need the intersection point given by the parameter t and not only x,y coordinates. I found out that Solve is MUCH faster when the curve is given in implicit form rather than in parametric form. Unfortunatly that doesn't help me (at least I don't know how). Is there any way to speed up the calculation?
r[t_] := {Cos[t], Sin[t]}(*parametric curve*)
uT[t_] :=
Simplify[r'[t]/Norm[r'[t]], t \[Element] Reals](*tangent vector at t*)
uN[t_] :=
Simplify[uT'[t]/Norm[uT[t]], t \[Element] Reals](*normal vector at t*)
t0 = 0;(*start parameter t*)
a0 = 45.1/180*\[Pi]; (*start parameter a; a=angle between tangent vector \
and ray*)
T = {t0};
A = {a0};
trace[t0_, a0_, n_] := Module[{t = t0, a = a0},
Do[
rr = RotationMatrix[a].uT[t];
(*res2=Solve[{xx^2+yy^2==1,yy==rr[[2]]/rr[[1]]*xx+(r0[[2]]*
rr[[1]]-rr[[2]]*r0[[1]])/rr[[1]]},{xx,yy},Reals];*)
res = FindInstance[
Reduce[{r[tt] == r[t] + k*rr, Abs[k] > 10^(-10), tt < 2 \[Pi],
tt >= 0}, {tt, k}], {k, tt}];
AppendTo[T, tt /. res[[1]]];
t = tt /. res[[1]];
rr = 2*(uT[t].rr)*uT[t] - rr;
a = ArcCos[rr.uT[t]];
AppendTo[A, a];
, {i, n}]
];
trace[t0, a0, 10]
Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. >>
Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. >>
Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. >>
General::stop: Further output of Reduce::ratnz will be suppressed during this calculation. >>
Show[
ParametricPlot[{r[t]}, {t, 0, 2 \[Pi]}],
ListLinePlot[r /@ T]]