# Animated point following a sinusoidal path on sphere

Could someone help me with animating a point following a $\sin$-like path on the sphere? It should be something like this:

This green point should walking on a sine (this red line) around sphere. • Would you not derive a formula of a line along which your point should travel? – Alexei Boulbitch May 23 '16 at 13:47
• Welcome! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – user9660 May 23 '16 at 14:11

Here you go,

sphereplot = With[
{z = 1/2 Cos[8 ϕ], r = 1},
Show[
Graphics3D@Sphere[],
ParametricPlot3D[{Cos[ϕ] Sqrt[r^2 - z^2],
Sin[ϕ] Sqrt[r^2 - z^2], z}, {ϕ, 0, 2 π}],
Boxed -> False
]
]; Now you just need a function that will place the animation point at a given angle around the curve,

ball[ϕ_] := With[
{z = 1/2 Cos[8 ϕ], r = 1},
Show[sphereplot,
Graphics3D[{Red,
Sphere[{Cos[ϕ] Sqrt[r^2 - z^2], Sin[ϕ] Sqrt[r^2 - z^2],
z}, .1]}],
ViewPoint -> {1.8, -2.8, 0.37},
ViewVertical -> {0.255, -0.4, 0.9},
PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}, {-1.1, 1.1}}
]]


Now you generate a list of images,

imglist = ball /@ Range[0, 2 π, .05];


and animate with ListAnimate

ListAnimate@imglist ClearAll[f]
f[p_, a_] := {Cos[a Sin[p #1]] Cos[#1], Cos[a Sin[p #1]] Sin[#1], -Sin[a Sin[p #1]]} &;
sphere = Graphics3D[{Opacity[0.7], Sphere[]}];

Dynamic[Show[sphere, ParametricPlot3D[f[10, .25][u], {u, 0, 2 Pi]},
Mesh -> {{{Clock[{0, 2 Pi}], {Red, PointSize[.05]}}}},
MeshFunctions -> {#4 &}], Boxed -> False] /. Point[x_] :> Sphere[x, .05]] Manipulate[Animate[Show[sphere, ParametricPlot3D[f[p, a][u], {u, 0, 2 Pi},
Mesh -> {{{t, Directive[Red, PointSize[Large]]}}},
MeshFunctions -> {#4&}] /. {Line[x_] :> Tube[x, .025], Point[x_] :> Sphere[x, .05]}],
{t, 0, 2 Pi}], {{a, .5}, 0, 1, .1}, {{p, 4}, 2, 10, 1}] With[{path = CoordinateTransform[
"Spherical" -> "Cartesian", {1, (Sin[5 fi] .5 + Pi/2), fi}
]}
,
Show[
ParametricPlot3D[path, {fi, -Pi, Pi}],
Graphics3D[{Sphere[], AbsolutePointSize @ 12,
Dynamic[Point[1.01 path /. fi -> Clock[2 Pi, 3]], UpdateInterval -> .05]}],
PlotRange -> 1.5]
] 