Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- eq = {x''[t] == -k*(x[t] - r[t]*Cos[theta]),
- r''[t] == -k*(r[t] - x[t]*Cos[theta])};
- theta = Pi/4; k = 1;
- ic = {x[0] == 1, r[0] == 0, x'[0] == 0, r'[0] == 0};
- sol = NDSolve[{eq, ic}, {x, r}, {t, 0, 20}]
- lst = Table[
- Graphics[{{Line[{{-1, 0}, {1, 0}}],
- Line[{{-Cos[theta], -Sin[theta]}, {Cos[theta],
- Sin[theta]}}]}, {Green,
- Line[{{x[t], 0}, {r[t]*Cos[theta], r[t]*Sin[theta]}} /.
- sol]}, {Red, PointSize[.05], Point[{x[t], 0} /. sol],
- Point[{r[t]*Cos[theta], r[t]*Sin[theta]} /. sol]}}], {t, 0,
- 10, .1}];
- ListAnimate[lst]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement