如何在给定数学旋转轴的情况下为3d绘制动画

时间:2011-02-28 22:46:38

标签: wolfram-mathematica

如果给定一个标准化的旋转轴,例如{1 / Sqrt [3],1 / Sqrt [3],1 / Sqrt [3]}和3d图,

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}]

我想为这个关于轴{1 / Sqrt [3],1 / Sqrt [3],1 / Sqrt [3]}(可能是任何其他任意一个)的图创建一个动画,然后将其导出作为GIF动画。有人请帮忙吗?非常感谢。

修改

我在指定旋转方面也遗漏了一个自由度。任何人都可以帮助,如果还给出旋转轴必须通过的点的坐标,如何进行可视化/动画? 再次感谢。

2 个答案:

答案 0 :(得分:7)

复制Daniel所做的事情,准备出口。

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

以下参数可用于gif导出(根据文档):

"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

我过去使用过“DisplayDurations”,但它确实有效。

答案 1 :(得分:6)

可以执行以下操作。

axis = {1, 1, 1};

Animate[
  Plot3D[2*z[x, y], {x, -5, 5}, {y, -5, 5}] /. 
    gg : GraphicsComplex[___] :> Rotate[gg, theta, axis],
  {theta, 0., 2.*Pi}]

enter image description here

Daniel Lichtblau Wolfram Research