-1
$\begingroup$

Given:

r[t_] := {Sin[t], Sin[2 t]}
uT[t_] := Simplify[r'[t]/Norm[r'[t]], t \[Element] Reals]

Animate[Show[ParametricPlot[{r[t]}, {t, -\[Pi], \[Pi]}],
Graphics[{{Line[{{Sin[t], Sin[2 t]}, {-(Cos[t]/Sqrt[Cos[t]^2 + 4 Cos[2 t]^2]) +
Sin[t], -((2 Cos[2 t])/Sqrt[Cos[t]^2 + 4 Cos[2 t]^2]) +
Sin[2 t]}}]}}], PlotRange -> {{-2, 2}, {-2, 2}}], {t, 0, 2 \[Pi]},
AnimationRunning -> False]

enter image description here

How do I replace the line with a triangle, to follow the curve as the picture below shows?

enter image description here

$\endgroup$
3
  • $\begingroup$ You changed your problem definition, but you failed to keep a record of that in your question. Now my answer is lingering as if I didn't understand your problem. Please edit the question to reflect that the initial statement has been changed. Thank you. $\endgroup$ Oct 24, 2013 at 17:38
  • $\begingroup$ @belisarius I suggest you edit the question yourself to include what you were originally answering; IMO this is appropriate such cases. $\endgroup$
    – Mr.Wizard
    Oct 24, 2013 at 18:24
  • $\begingroup$ @Mr.Wizard The original question didn't have the specification for the triangle orientation. I'm trying to offer the OP the opportunity to be courteous. $\endgroup$ Oct 24, 2013 at 18:29

4 Answers 4

11
$\begingroup$
<< Polytopes`
v = 1/10 Vertices[Triangle];
tri0 = {Translate[Rotate[ Line@ { v, RotateLeft@v}, Pi/2, {0, 0}], {0, 1/2 v[[1, 2]]}]};
tri[tri0_, pos_, angle_] := Translate[Rotate[tri0, angle, {0, 0}], pos]
ang[t_] := If[# === Indeterminate, Pi/2, #] &@ (ArcTan[k'[p][[2]]/k'[p][[1]]] /. p -> t)

k[t_] := {Cos[3 t], Sin[ 2 t ]};
Manipulate[ParametricPlot[k[t], {t, 0, 2 Pi}, Epilog -> tri[tri0, k[m], ang[m]]], {m, 0, 2 Pi}]

enter image description here

$\endgroup$
6
$\begingroup$

One way is to use a custom arrowhead:

plot = ParametricPlot[{r[t]}, {t, -Pi, Pi}];
tri = Graphics[{EdgeForm[Directive[Opacity[1], Purple, Thick]], 
    Opacity[0], Polygon[{{0, 0}, {-1, 0.5}, {-1, -0.5}}]}];

Animate[Show[
  plot, 
  Graphics[{
    Arrowheads[{{Automatic, Automatic, tri}}], 
    Opacity[0], Arrow[{r[t] - 0.1 r'[t], r[t]}]}],
  PlotRange -> {{-2, 2}, {-2, 2}}],
 {t, 0, 2 Pi}, AnimationRunning -> False]

Mathematica graphics

One could also use a small, finite difference Arrow[{r[t - 0.01], r[t]}] instead of the derivative above.

$\endgroup$
5
$\begingroup$

Given a trajectory {x[t],y[t]}, the velocity vector is tangent D[{x[t],y[t]},t].

To find the angle that the velocity vector makes with the x axis you can use ArcTan. Because of the initial orientation of your triangle definition, we also have to add Pi/2.

Animate[
 Show[
  Graphics[{Translate[Rotate[
      {Line[{{9/2, 7}, {7/2, 7}, {4, 3}, {9/2, 7}}]},
      Pi/2 + ArcTan[Cos[t], 2 Cos[2 t]], {4, 3}],{Sin[t], Sin[2 t]}],
    PointSize[Large], Red, Point[{Sin[t], Sin[2 t]}+{4,3}]
  },PlotRange -> {{-2, 10}, {-2, 10}}],
ParametricPlot[{Sin[x], Sin[2 x]}+{4,3}, {x, 0, 2 Pi}]
], {t, 0, 2 Pi}, AnimationRunning -> False]
$\endgroup$
4
$\begingroup$

Variation on a theme (but using equilateral triangle not arbitrary)

mt[u_] := 
 Prepend[Differences[
    Join @@ NestList[{#[[2]], 
        RotationTransform[60 Degree, #[[2]]][#[[1]]]} &, {Normalize@u,
        1.1 Normalize@u}, 3]] /. {0., 0.} -> Sequence[], {0, 0}]
fnc[t_] := {Cos[3 t], Sin[2 t]};
tg[u_] := D[fnc[t], t] /. t -> u;
Manipulate[
 ParametricPlot[fnc[t], {t, 0, 2 Pi}, 
  Epilog -> Polygon[(fnc[q] + # & /@ mt[tg[q]])], 
  PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}}], {q, 0, 2 Pi}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.