3
$\begingroup$

Here's a Manipulate code to show a particular 3D surface, rotating uniformly in time. The point of this Manipulate box is to show that the surface do indeed rotate like a solid, so I can't "cheat" with its evolution to get some better performance.

Manipulate[
SphericalPlot3D[
1/(16Pi)(8Cos[4(phi - t)]Sin[theta]^4 - 35 - 28Cos[2theta] - Cos[4theta]),
{theta, 0, Pi}, {phi, 0, 2 Pi},
ColorFunction -> Function[{x, y, z, theta, phi, r}, ColorData["Rainbow"][r]],
Mesh -> {18, 7},
PlotPoints -> {32, 24},
MaxRecursion -> ControlActive[0, 2],
PlotRange -> {{-1, 1}, {-1, 1}, {-1.5, 1.5}},
Boxed -> False,
Axes -> True,
AxesStyle -> Directive[RGBColor[0.50, 0.50, 0.90], Dashed],
AxesOrigin -> {0, 0, 0},
Ticks -> None,
PerformanceGoal -> "Quality",
SphericalRegion -> True,
Method -> {"RotationControl" -> "Globe"},
ImageSize -> {500, 500}
],
{{t, 0, Style["t", 10]},
    0, 2 Pi, 0.01,
    ImageSize -> Large,
    Appearance -> {"Labeled", "Open"},
    AnimationRate -> 8 Pi,
    DisplayAllSteps -> True}
]

Now, if you watch closely the animation, you'll see that the vertical subdivision grid do not rotate with the surface. It is fixed relative to the observer, and the mesh gets some deformations at some places while the surface rotate.

So how can I make the vertical lines to rotate with the surface ?

$\endgroup$
6
$\begingroup$

In order to have the illusion of moving mesh lines, you must make the values at which your vertical mesh lines are drawn explicitly dependent on the current value of $t$.

Substitute the following in your code above:

Mesh -> {18, Range[-3 Pi, 2 Pi, Pi/7] + t}

enter image description here

$\endgroup$
  • $\begingroup$ Cool ! I'll try this later today when I'll be back home. How is the performance on your system ? Is the animation slow and laggy ? $\endgroup$ – Cham Mar 7 '16 at 19:48
  • $\begingroup$ is there a way to remove that long "fold like" line that is showing on one side of the surface ? This line has nothing to do with your solution, but it annoys me a lot. $\endgroup$ – Cham Mar 7 '16 at 22:09
  • $\begingroup$ Using BoundaryStyle -> None removed that unwanted line, but there's still a visible "fold" on the surface. That fold-like is actually a cut on the surface. How to get rid of it ? $\endgroup$ – Cham Mar 7 '16 at 23:17
  • $\begingroup$ I found a simpler method to get the same result : just change {phi, 0, 2Pi} to {phi, t, 2Pi + t}. $\endgroup$ – Cham Mar 8 '16 at 14:02
1
$\begingroup$

The simplest solution to my problem is simply to adapt the azimuthal range to time :

{phi, 0, 2Pi} --> {phi, t, 2Pi + t},

which gives this code :

Manipulate[
    SphericalPlot3D[
        1/(16Pi)(8Cos[4(phi - t)]Sin[theta]^4 - 35 - 28Cos[2theta] - Cos[4theta]),
        {theta, 0, Pi}, {phi, t, 2Pi + t},
        ColorFunction -> Function[{x, y, z, theta, phi, r}, ColorData["Rainbow"][r]],
        Mesh -> {18, 7},
        PlotPoints -> {32, 24},
        MaxRecursion -> ControlActive[0, 2],
        PlotRange -> All,
        Boxed -> False,
        Axes -> True,
        AxesStyle -> Directive[RGBColor[0.50, 0.50, 0.90], Dashed],
        AxesOrigin -> {0, 0, 0},
        Ticks -> None,
        PerformanceGoal -> "Quality",
        SphericalRegion -> True,
        Method -> {"RotationControl" -> "Globe"},
        ImageSize -> {500, 500}
    ],
    {{t, 0, Style["t", 10]}, 0, 2Pi, 0.01,
    ImageSize -> Large,
    Appearance -> {"Labeled", "Open"},
    AnimationRate -> 8 Pi,
    DisplayAllSteps -> True}
]

This solution even fixes an aesthetical problem I had with a "cut" line shown between phi = 0 and phi = 2Pi, without using the normals defined here (which is having a high impact on performances under a Manipulate box) : How to remove a small gap (fold-like line) on a closed 3D surface?

$\endgroup$
  • $\begingroup$ Excellent! (+1) $\endgroup$ – MarcoB Mar 8 '16 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.