2011-02-28 103 views
4

如果给定旋转轴归一化,例如{1/Sqrt [3],1/Sqrt [3],1/Sqrt [3]}和3d图,例如,如何在数学中赋予旋转轴动画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。会有人请帮忙吗?非常感谢。

编辑

我也留下了一个自由度在指定的旋转。如果还给出了旋转轴必须通过的点的坐标,那么是否有人可以提供帮助?如何进行可视化/动画? 再次感谢。

+0

我恳求你审查你的决定,接受丹尼尔的答案,而不是我的。我在那里复制了代码,只是添加了导出功能,没有什么大不了的。获得15分只是为了复制和粘贴而感到羞耻。谢谢! - – 2011-03-04 22:25:37

+0

@belisarius:我明白了,我会按照你在这里所要求的去做。 :)最初我想到了这个,我认为你是一个完整的解决方案。阅读这篇文章的人会更容易。但无论如何... – 2011-03-04 22:32:47

回答

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

丹尼尔Lichtblau 沃尔夫勒姆研究

+0

@Daniel:非常感谢。你碰巧记得如何导出动画? – 2011-02-28 23:32:11

+0

@强要导出更容易制作一个表[]与绘图,然后导出[“filename.gif”,tableWithPlots] – 2011-02-28 23:52:54

+0

@belisarius:你能否给出一个完整的解决方案来做导出部分? – 2011-03-01 00:00:22

7

复制什么丹尼尔一样,只是准备出口。

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”,和它的工作。

+0

非常感谢。我只是想知道是否有一种自动的方式来选择PlotRange用于此目的。有时候,看图表来猜测范围是相当困难的。 – 2011-03-01 19:31:22

+0

@Daniel,@belisarius:与输出动画gif相比,Animate生成的图片非常差。你有没有注意到同样的效果?我想知道为什么是这样的情况;也许Animate有改进? – 2011-03-01 19:32:39

+0

@强李:gif更好的原因是数据不是一路计算的。像上面那样用s试一下'ListAnimate [s]'。有帧速率等选项 – Janus 2011-03-02 01:55:02