I am modelling a spinning top on a sphere and I want to obtain plots such as these
I have solved the equations of motion
B = 1;
a = 1;
sol = NDSolve[{p'[t] == (B - a*Cos[th[t]])/(Sin[th[t]]^2),
th''[t] == (p'[t]*(p'[t]*Cos[th[t]] - a) + 1)*Sin[th[t]],
th[0] == 1, p[0] == 0, th'[0] == 0}, {p, p', th, th'}, {t, 0, 10} ]
Then to plot the points I evaluate
a = Flatten[Table[th[t] /. sol, {t, 0, 10}]]
b = Flatten[Table[p[t] /. sol, {t, 0, 10}]]
res = Transpose[{Table[1, {t, 0, 10}], a, b
}] (*I want all points on a unit sphere*)
Then following what is in this question I do
Graphics3D@{Sphere[{0, 0, 0}, 1],
Point[CoordinateTransformData["Spherical" -> "Cartesian",
"Mapping", #] & /@ res]}
But I get back all sorts of errors as below
Why so? It looks like this is because my angles phi get quite large as I got around the sphere (n rotations would be 2nPi).
The outputs of NDSolve are the following:
I think the issue can be solved if all the coordinates theta and phi can be mapped into the range allowed by the coordinate transformation. Mathematica seems to require phi between -pi and pi. So theta should be between 0 and pi. How do I do this? (Very new to mathematica)