Skip to main content
Routine clean-up
Source Link
m_goldberg
  • 108.2k
  • 16
  • 104
  • 259

An autorotating figure Figure in animated GIF is oscillating as it rotates

I'm trying to draw a figure as shown below and letmake it rotate around the vertical axis (z-axis) automatically.

Figure to be rotated

This is how I generate the figure and letmake it rotate:

\[CapitalDelta]\[Phi]Δϕ = \[Pi]π 14.0/13.0;
p1 = 
  Show[
  Table[RegionPlot3D[  Table[
      RegionPlot3D[
        x^2 + y^2 + (z - j)^2 < 
   0.5^2 && 
        (x - 0.4 Cos[j \[CapitalDelta]\[Phi]]Δϕ]) Cos[
      jCos[j \[CapitalDelta]\[Phi]]Δϕ] + (y - 
       0.4 Sin[j \[CapitalDelta]\[Phi]]Δϕ]) Sin[
Sin[j Δϕ] < 0,  
   j \[CapitalDelta]\[Phi]] < 0,  {x, -0.5, 0.5}, {y, -0.5, 
  0.5}, {z, -0.5 + j, 0.5 + j}, 
        PlotStyle -> Blue, 
 Mesh -> None], 
      {j, 0, 5}], 
      PlotRange -> All, 
 BoxRatios -> Automatic];
p2 = 
  Graphics3D[
 Table[Arrow[   Table[
      Arrow[{{0.4 Cos[j \[CapitalDelta]\[Phi]]Δϕ], 
   0.4 Sin[j \[CapitalDelta]\[Phi]]Δϕ], 
   j}, {Cos[j \[CapitalDelta]\[Phi]]Δϕ], 
   Sin[j \[CapitalDelta]\[Phi]]Δϕ], j}}], 
      {j, 0, 5}]];
p = 
  Show[{p1, p2}, 
    Boxed -> False, Axes -> False, 
    ViewPoint -> {0, -10, 0}, ViewCenter -> {0, 0, 2.5}, 
    ViewVertical -> {0, 0, 1}];
vc = AbsoluteOptions[p, ViewCenter][[1, 2]];
vp = AbsoluteOptions[p, ViewPoint][[1, 2]];
m = RotationMatrix [5 Degree, {0., 0., 1.}];
newvp = m.(vp - vc);
Export["a.gif", 
  Table[Show[pTable[
    Show[p, 
      ViewPoint -> MatrixPower[m, j].(vp - vc) + vc, 
      PlotRange -> All], 
    {j, 0, 360/5 - 1}]];

This is how the gif file looks like The output gif file

I don't understand why the gif is kind of oscillating in the horizontal direction, and the arrows seem turn around when a cycle is done and the next cycle starts. What I want is to have the rotating axis (here the z-axis) fixed while the figure is rotating. Which part of my code is wrong?

An autorotating figure is oscillating

I'm trying to draw a figure as below and let it rotate around the vertical axis (z-axis) automatically

Figure to be rotated

This is how I generate the figure and let it rotate

\[CapitalDelta]\[Phi] = \[Pi] 14.0/13.0;
p1 = Show[
  Table[RegionPlot3D[
  x^2 + y^2 + (z - j)^2 < 
   0.5^2 && (x - 0.4 Cos[j \[CapitalDelta]\[Phi]]) Cos[
      j \[CapitalDelta]\[Phi]] + (y - 
       0.4 Sin[j \[CapitalDelta]\[Phi]]) Sin[
      j \[CapitalDelta]\[Phi]] < 0, {x, -0.5, 0.5}, {y, -0.5, 
  0.5}, {z, -0.5 + j, 0.5 + j}, PlotStyle -> Blue, 
 Mesh -> None], {j, 0, 5}], PlotRange -> All, 
 BoxRatios -> Automatic];
p2 = Graphics3D[
 Table[Arrow[{{0.4 Cos[j \[CapitalDelta]\[Phi]], 
   0.4 Sin[j \[CapitalDelta]\[Phi]], 
   j}, {Cos[j \[CapitalDelta]\[Phi]], 
   Sin[j \[CapitalDelta]\[Phi]], j}}], {j, 0, 5}]];
p = Show[{p1, p2}, Boxed -> False, Axes -> False, 
 ViewPoint -> {0, -10, 0}, ViewCenter -> {0, 0, 2.5}, 
 ViewVertical -> {0, 0, 1}];
vc = AbsoluteOptions[p, ViewCenter][[1, 2]];
vp = AbsoluteOptions[p, ViewPoint][[1, 2]];
m = RotationMatrix [5 Degree, {0., 0., 1.}];
newvp = m.(vp - vc);
Export["a.gif", 
  Table[Show[p, ViewPoint -> MatrixPower[m, j].(vp - vc) + vc, 
  PlotRange -> All], {j, 0, 360/5 - 1}]];

This is how the gif file looks like The output gif file

I don't understand why the gif is kind of oscillating in the horizontal direction, and the arrows seem turn around when a cycle is done and the next cycle starts. What I want is to have the rotating axis (here the z-axis) fixed while the figure is rotating. Which part of my code is wrong?

Figure in animated GIF is oscillating as it rotates

I'm trying to draw a figure as shown below and make it rotate around the vertical axis (z-axis) automatically.

Figure to be rotated

This is how I generate the figure and make it rotate:

Δϕ = π 14.0/13.0;
p1 = 
  Show[
    Table[
      RegionPlot3D[
        x^2 + y^2 + (z - j)^2 < 0.5^2 && 
        (x - 0.4 Cos[j Δϕ]) Cos[j Δϕ] + (y - 0.4 Sin[j Δϕ]) Sin[j Δϕ] < 0,  
        {x, -0.5, 0.5}, {y, -0.5, 0.5}, {z, -0.5 + j, 0.5 + j}, 
        PlotStyle -> Blue, Mesh -> None], 
      {j, 0, 5}], 
      PlotRange -> All, BoxRatios -> Automatic];
p2 = 
  Graphics3D[
    Table[
      Arrow[{{0.4 Cos[j Δϕ], 0.4 Sin[j Δϕ], j}, {Cos[j Δϕ], Sin[j Δϕ], j}}], 
      {j, 0, 5}]];
p = 
  Show[{p1, p2}, 
    Boxed -> False, Axes -> False, 
    ViewPoint -> {0, -10, 0}, ViewCenter -> {0, 0, 2.5}, 
    ViewVertical -> {0, 0, 1}];
vc = AbsoluteOptions[p, ViewCenter][[1, 2]];
vp = AbsoluteOptions[p, ViewPoint][[1, 2]];
m = RotationMatrix [5 Degree, {0., 0., 1.}];
newvp = m.(vp - vc);
Export["a.gif", 
  Table[
    Show[p, 
      ViewPoint -> MatrixPower[m, j].(vp - vc) + vc, 
      PlotRange -> All], 
    {j, 0, 360/5 - 1}]];

This is how the gif file looks like The output gif file

I don't understand why the gif is kind of oscillating in the horizontal direction, and the arrows seem turn around when a cycle is done and the next cycle starts. What I want is to have the rotating axis (here the z-axis) fixed while the figure is rotating. Which part of my code is wrong?

Tweeted twitter.com/StackMma/status/702657018302177280
edited tags
Link
deleted 3 characters in body
Source Link
David G. Stork
  • 42.3k
  • 3
  • 37
  • 106

I'm trying to draw a figure as blowbelow and let it rotate around the vertical axis (z-axis) automatically

Figure to be rotated

This is how I generate the figure and let it rotate

\[CapitalDelta]\[Phi] = \[Pi] 14.0/13.0;
p1 = Show[
  Table[RegionPlot3D[
  x^2 + y^2 + (z - j)^2 < 
   0.5^2 && (x - 0.4 Cos[j \[CapitalDelta]\[Phi]]) Cos[
      j \[CapitalDelta]\[Phi]] + (y - 
       0.4 Sin[j \[CapitalDelta]\[Phi]]) Sin[
      j \[CapitalDelta]\[Phi]] < 0, {x, -0.5, 0.5}, {y, -0.5, 
  0.5}, {z, -0.5 + j, 0.5 + j}, PlotStyle -> Blue, 
 Mesh -> None], {j, 0, 5}], PlotRange -> All, 
BoxRatios -> Automatic];
p2 = Graphics3D[
 Table[Arrow[{{0.4 Cos[j \[CapitalDelta]\[Phi]], 
   0.4 Sin[j \[CapitalDelta]\[Phi]], 
   j}, {Cos[j \[CapitalDelta]\[Phi]], 
   Sin[j \[CapitalDelta]\[Phi]], j}}], {j, 0, 5}]];
p = Show[{p1, p2}, Boxed -> False, Axes -> False, 
 ViewPoint -> {0, -10, 0}, ViewCenter -> {0, 0, 2.5}, 
 ViewVertical -> {0, 0, 1}];
vc = AbsoluteOptions[p, ViewCenter][[1, 2]];
vp = AbsoluteOptions[p, ViewPoint][[1, 2]];
m = RotationMatrix [5 Degree, {0., 0., 1.}];
newvp = m.(vp - vc);
Export["a.gif", 
  Table[Show[p, ViewPoint -> MatrixPower[m, j].(vp - vc) + vc, 
  PlotRange -> All], {j, 0, 360/5 - 1}]];

This is how the gif file looks like The output gif file

I don't understand why the gif is kind of oscillating in the horizontal direction, and the arrows seem turn around when a cycle is done and the next cycle starts. What I want is to have the rotating axis (here the z-axis) fixed while the figure is rotating. Which part of my code is wrong?

I'm trying to draw a figure as blow and let it rotate around the vertical axis (z-axis) automatically

Figure to be rotated

This is how I generate the figure and let it rotate

\[CapitalDelta]\[Phi] = \[Pi] 14.0/13.0;
p1 = Show[
  Table[RegionPlot3D[
  x^2 + y^2 + (z - j)^2 < 
   0.5^2 && (x - 0.4 Cos[j \[CapitalDelta]\[Phi]]) Cos[
      j \[CapitalDelta]\[Phi]] + (y - 
       0.4 Sin[j \[CapitalDelta]\[Phi]]) Sin[
      j \[CapitalDelta]\[Phi]] < 0, {x, -0.5, 0.5}, {y, -0.5, 
  0.5}, {z, -0.5 + j, 0.5 + j}, PlotStyle -> Blue, 
 Mesh -> None], {j, 0, 5}], PlotRange -> All, 
BoxRatios -> Automatic];
p2 = Graphics3D[
 Table[Arrow[{{0.4 Cos[j \[CapitalDelta]\[Phi]], 
   0.4 Sin[j \[CapitalDelta]\[Phi]], 
   j}, {Cos[j \[CapitalDelta]\[Phi]], 
   Sin[j \[CapitalDelta]\[Phi]], j}}], {j, 0, 5}]];
p = Show[{p1, p2}, Boxed -> False, Axes -> False, 
 ViewPoint -> {0, -10, 0}, ViewCenter -> {0, 0, 2.5}, 
 ViewVertical -> {0, 0, 1}];
vc = AbsoluteOptions[p, ViewCenter][[1, 2]];
vp = AbsoluteOptions[p, ViewPoint][[1, 2]];
m = RotationMatrix [5 Degree, {0., 0., 1.}];
newvp = m.(vp - vc);
Export["a.gif", 
  Table[Show[p, ViewPoint -> MatrixPower[m, j].(vp - vc) + vc, 
  PlotRange -> All], {j, 0, 360/5 - 1}]];

This is how the gif file looks like The output gif file

I don't understand why the gif is kind of oscillating in the horizontal direction, and the arrows seem turn around when a cycle is done and the next cycle starts. What I want is to have the rotating axis (here the z-axis) fixed while the figure is rotating. Which part of my code is wrong?

I'm trying to draw a figure as below and let it rotate around the vertical axis (z-axis) automatically

Figure to be rotated

This is how I generate the figure and let it rotate

\[CapitalDelta]\[Phi] = \[Pi] 14.0/13.0;
p1 = Show[
  Table[RegionPlot3D[
  x^2 + y^2 + (z - j)^2 < 
   0.5^2 && (x - 0.4 Cos[j \[CapitalDelta]\[Phi]]) Cos[
      j \[CapitalDelta]\[Phi]] + (y - 
       0.4 Sin[j \[CapitalDelta]\[Phi]]) Sin[
      j \[CapitalDelta]\[Phi]] < 0, {x, -0.5, 0.5}, {y, -0.5, 
  0.5}, {z, -0.5 + j, 0.5 + j}, PlotStyle -> Blue, 
 Mesh -> None], {j, 0, 5}], PlotRange -> All, 
BoxRatios -> Automatic];
p2 = Graphics3D[
 Table[Arrow[{{0.4 Cos[j \[CapitalDelta]\[Phi]], 
   0.4 Sin[j \[CapitalDelta]\[Phi]], 
   j}, {Cos[j \[CapitalDelta]\[Phi]], 
   Sin[j \[CapitalDelta]\[Phi]], j}}], {j, 0, 5}]];
p = Show[{p1, p2}, Boxed -> False, Axes -> False, 
 ViewPoint -> {0, -10, 0}, ViewCenter -> {0, 0, 2.5}, 
 ViewVertical -> {0, 0, 1}];
vc = AbsoluteOptions[p, ViewCenter][[1, 2]];
vp = AbsoluteOptions[p, ViewPoint][[1, 2]];
m = RotationMatrix [5 Degree, {0., 0., 1.}];
newvp = m.(vp - vc);
Export["a.gif", 
  Table[Show[p, ViewPoint -> MatrixPower[m, j].(vp - vc) + vc, 
  PlotRange -> All], {j, 0, 360/5 - 1}]];

This is how the gif file looks like The output gif file

I don't understand why the gif is kind of oscillating in the horizontal direction, and the arrows seem turn around when a cycle is done and the next cycle starts. What I want is to have the rotating axis (here the z-axis) fixed while the figure is rotating. Which part of my code is wrong?

Source Link
ruima86
  • 273
  • 1
  • 6
Loading