Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to animate 3d plot given a rotation axis in mathematics

If given a rotation axis normalized, such as {1/Sqrt[3],1/Sqrt[3],1/Sqrt[3]}, and a 3d plot, for example,

z[x_, y_] := Exp[-(Sqrt[x^2 + y^2]/Power[4, (3)^-1]) + Power[4, (3)^-1]*Sqrt[1/2*(Sqrt[x^2 + y^2] + x)]];

Plot3D[2*z[x, y], {x, -5, 5}, {y, -5, 5}]

I want to create an animation for this plot about the axis {1/Sqrt[3],1/Sqrt[3],1/Sqrt[3]} (could be any other arbitary one), and then export it as an animated gif. Would anyone please help? Many thanks.

Edit

I also left out one degree of freedom in specifying the rotation. Could any one please help, if also given the coordinate of a point which the rotational axis must pass, how to do the visualization/animation? Thanks again.

like image 926
Qiang Li Avatar asked Dec 13 '22 15:12

Qiang Li


1 Answers

Copying what Daniel did, just prepared for exporting.

axis = {1, 1, 1};
l = {-7, 7};

s = Table[

      Plot3D[2*z[x, y], {x, -5, 5}, {y, -5, 5}, PlotRange -> {l, l, l}] /. 

      gg : GraphicsComplex[___] :> Rotate[gg, theta, axis], {theta, 0., 2. Pi}];

Export["c:\\test.gif", s]

enter image description here

The following parameters are available for the gif export (as per the docs):

"AnimationRepetitions" how many times the animation is played before stopping
"Background"           background color shown in transparent image regions 
"BitDepth"             bits used to represent each color channel in the file
"ColorMap"             color reduction palette, given as a list of color values
"GlobalColorMap"       default color palette for individual animation frames
"DisplayDurations"     display durations of animation frames, given in seconds
"ImageCount"           number of frames in an animated GIF
"ImageSize"            overall image size
"RawData"              array of color map indices
"Comments"             user comments stored in the file

I used "DisplayDurations" in the past, and it worked.

like image 54
Dr. belisarius Avatar answered Dec 15 '22 06:12

Dr. belisarius