Advertisement
Matthen

Osculating circle

Jul 6th, 2014
1,046
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. x[t_] := t;
  2. y[t_] := Sin[t]
  3. r[t_] := {x[t], y[t]};
  4.  
  5. curvature[t_] = Abs[D[D[y[t], t], t]]/(1 + (D[y[t], t])^2)^(3/2);
  6. radius[t_] = If[curvature[t] == 0, 99999, 1/curvature[t]];
  7.  
  8. T[t_] = D[r[t], t]/Sqrt[D[r[t], t].D[r[t], t]];
  9. Tprime[t_] = D[T[t], t];
  10.  
  11. circle[t_] := Module[{NNN, center, xc, yc},
  12. NNN = If[Tprime[t] == {0, 0}, {0, 0},
  13. Tprime[t]/Sqrt[Tprime[t].Tprime[t]]];
  14.  
  15. center = radius[t]*NNN + r[t];
  16. xc = Extract[center, 1];
  17. yc = Extract[center, 2];
  18. {{xc, yc}, radius[t]}
  19. ];
  20. frame[tt_] :=
  21. Show[
  22. Graphics[
  23. {EdgeForm[Gray], FaceForm[RGBColor[0.95, 0.95, 1.0]],
  24. Module[{p, r},
  25. {p, r} = circle[tt];
  26. {
  27. Circle[p - {tt, 0}, r],
  28. Point[p - {tt, 0}],
  29. Gray,
  30. Line[{p - {tt, 0}, {0, y[tt]}}]
  31. }
  32. ]}
  33. , PlotRange -> {window {-1, 1}, {-5, 5}}],
  34. Plot[y[t + tt], {t, -window, window},
  35. PlotStyle ->
  36. Directive[Thick, Opacity[0.8], RGBColor[0.2, 0.3, 0.9]]]
  37. ];
  38. Manipulate[
  39. frame[tt],
  40. {tt,0,2Pi}
  41. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement