How can I show that a sphere is rolling in a simulation?
Any reason why you want to show a Sphere
? To my mind using another shape would be a lot more fun. Here's m_goldberg's code with a demo from SphericalPlot3D
:
myWheel =
SphericalPlot3D[
.8 + Sin[5 ϕ]/5, {θ, 0, Pi}, {ϕ, 0, 2 Pi},
PlotStyle -> Directive[Orange, Opacity[.9], Specularity[White, 10]],
Mesh -> None, PlotPoints -> 30
];
frames =
Table[
Graphics3D[
Rotate[
Translate[
myWheel[[1]],
{location[t], R, R}
],
zhuanjiao[t],
{0, 1, 0},
(*changed to get rolling to work*)
{location[t], R, R}
],
Axes -> True,
AxesEdge -> {{1, -1}, {-1, -1}, {-1, 1}},
Ticks -> None,
Boxed -> False,
Lighting -> "Neutral",
PlotRange -> {{0, 10}, {0, 2 R}, {0, 2 R}},
AxesLabel -> {x, y, z},
ViewPoint -> 4*{1, -2, .5}
],
{t, 0, 1, .05}
];
rast = Rasterize[#, ImageResolution -> 144] & /@ frames;
CloudExport[rast, "GIF", "test.gif", "AnimationRepetitions" -> Infinity, Permissions -> "Public"]
Well, you might do it by putting spots on the sphere. However, if you were to do that, you would the rotation you have imposed is not the rotation of a rolling ball. At least, it doesn't look it to me.
The following demonstrates a set of points, located on the surface of a ball, being moved and rotated by your functions location
and zhuanjiao
. Evaluate it to see what I mean.
R = 1;
v0 = 10; w0 = 8; mu = 0.2; g = 9.8;
δ = (2 (v0 + w0 R))/(5 mu g);
location[t_] :=
Piecewise[
{{If[t <= δ,
v0 t - 1/2* mu*g*t^2 + R,
(3 v0 - 2 w0 R)/5 (t - δ) + v0 δ - 1/2* mu*g*δ^2 + R],
3 v0 - 2 w0 R < 0}, (*<0 roll back*)
{If[t <= δ,
v0 t - 1/2* mu*g*t^2 + R,
v0 δ - 1/2* mu*g*δ^2 + R],
3 v0 - 2 w0 R == 0},
{If[t <= δ,
v0 t - 1/2* mu*g*t^2 + R,
(3 v0 - 2 w0 R)/5 (t - δ) + v0 δ - 1/2* mu*g*δ^2 + R],
3 v0 - 2 w0 R > 0}}]
zhuanjiao[t_] :=
If[t <= δ,
w0 t - (3 mu g)/(4 R) t^2,
w0 δ - (3 mu g)/(4 R) δ^2 - (3 v0 - 2 w0 R)/(5 R) (t - δ)]
Manipulate[
Graphics3D[
Rotate[
Translate[Point[SpherePoints[100]], {location[t], R, R}],
-zhuanjiao[t],
{1, 0, 0}, (* changed to get rolling to look right *)
{location[t], R, R}],
Axes -> True,
AxesOrigin -> {0, 0, 0},
PlotRange -> {{0, 10}, {0, 2 R}, {0, 2 R}},
AxesLabel -> {x, y, z}],
{t, 0, 1, .01}]