如何在数学钨创建2D(3D)动画与相机追随物体? [英] How to create 2D (3D) animation in Wolfram Mathematica with the camera following the object?

查看:211
本文介绍了如何在数学钨创建2D(3D)动画与相机追随物体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有沿着轨迹移动的图形对象。我怎样才能使相机效仿的对象?

I have a graphical object which is moving along a trajectory. How can I make the camera follow the object?

推荐答案

由于这个问题询问2D,这里是如何在2D图形模拟摄像头。

Since the question asks about 2D, here's how you can emulate a camera in 2D Graphics.

首先,让我们的计算器favicon.ico的:

First, let's get the stackoverflow favicon.ico:

so = First@Import["http://sstatic.net/stackoverflow/img/favicon.ico"]

那么把这个部分重叠的圆的顶部,使相机通过调整按照图标周围的 PlotRange

Manipulate[Graphics[{
   Table[Circle[{j, 0}, i], {i, 0, 1, .1}, {j, {-.5, .5}}],
   Inset[so, pos, {0, 0}, .2]},
  PlotRange -> {{-.5, .5}, {-.5, .5}} + pos],
 {{pos, {0, 0}, ""}, {-1.4, -1}, {1.4, 1}, ControlPlacement -> Left}]

要展示它是如何工作(与出将到上述数学),我们需要制作动画。
本来我选择了一个变步长随机游走酒后=累加[RandomReal [{ - 1,.1},{200,2}] ,但它是一个非predictable!因此,不是,我们做出的图标遵循 ABC 标志

To show how it works (with out putting the above into Mathematica), we need to animate it. Originally I chose a variable step random walk drunk = Accumulate[RandomReal[{-.1, .1}, {200, 2}]] but it was a unpredictable! So instead, we'll make the icon follow the ABC logo

drunk = Table[{1.5 Sin[t], Cos[3 t]}, {t, 0, 2 Pi, .1}];
Animate[Graphics[{
   Table[Circle[{j, 0}, i], {i, 0, 1, .1}, {j, {-.5, .5}}],
   Inset[so, drunk[[pos]], {0, 0}, .2]},
  PlotRange -> {{-.5, .5}, {-.5, .5}} + drunk[[pos]]],
 {pos, 1, Length[drunk], 1}]

这篇关于如何在数学钨创建2D(3D)动画与相机追随物体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆