# How to produce a chasing-view in Mathematica?

I would like to chase the flying plane with a video camera, how to do that in Mathematica?

R = 20 ;
pR = 30;
oR = 40 ;
highRng = {20 , 50 };
t = 0;
posts = Table[{Hue[RandomReal[]],
Cylinder[{{R Cos[ang], R Sin[ang], 0}, {R Cos[ang], R Sin[ang],
RandomInteger[highRng]}}]}, {ang, 0, 2 Pi, Pi/12}];

oposts = Table[{Hue[RandomReal[]],
Cylinder[{{oR Cos[ang], oR Sin[ang], 0}, {oR Cos[ang],
oR Sin[ang], RandomInteger[highRng]}}]}, {ang, 0, 2 Pi, Pi/12}];

(*********          link for the plane obj file:          ********)
(*  https://www.dropbox.com/s/7knvl519hg3s6qp/plane-4.obj?dl=0   *)

im = Import["https://www.dropbox.com/s/7knvl519hg3s6qp/plane-4.obj?dl=1"][[1]];

Dynamic[
Refresh[
t = t + 0.1 ;
Graphics3D[{posts, oposts, White,
Translate[
Rotate[im, t, {0, 0, 1}], {pR Cos[t], pR Sin[ t ], 20 + Sin[t]}]
} , PlotRange -> {All, All, {0, 50}},
Background -> Black, Boxed -> False
] ,
UpdateInterval -> 0.1 ] ,
TrackedSymbols -> {}
]

• Related: (3528), (5649) Commented Sep 19, 2014 at 10:49
• And perhaps 14480 Commented Sep 19, 2014 at 11:48
• I guess a first step would be finding the tangential vector with respect to the motion and using it as "ViewPoint" in the Graphics3D. Tangent vector
– gst
Commented Sep 19, 2014 at 13:08
• Since you are moving in a circle you could of course use the the angular unit vector of your polar coordinates.
– gst
Commented Sep 19, 2014 at 13:21
– kglr
Commented Sep 19, 2014 at 18:14

R = 20; pR = 30; oR = 40; highRng = {20, 50}; t = 0;
posts = Table[{Hue[RandomReal[]],
Cylinder[{{R Cos[ang], R Sin[ang], 0}, {R Cos[ang], R Sin[ang],
RandomInteger[highRng]}}]}, {ang, 0, 2 Pi, Pi/12}];
oposts = Table[{Hue[RandomReal[]], Cylinder[{{oR Cos[ang], oR Sin[ang], 0}, {oR Cos[ang],
oR Sin[ang], RandomInteger[highRng]}}]}, {ang, 0, 2 Pi, Pi/12}];
im = Import["https://www.dropbox.com/s/7knvl519hg3s6qp/plane-4.obj?dl=1"][[1]];

viewvector[t_] =
TranslationTransform[{pR Cos[t], pR Sin[t], 20 + Sin[t]}]@
(RotationTransform[t, {0, 0, 1}][{{0, 0, 0}, {0, 20, 0}}]);
pic1[t_] :=
Graphics3D[{posts, oposts, White,
Translate[Rotate[im, t, {0, 0, 1}], {pR Cos[t], pR Sin[t], 20 + Sin[t]}]},
PlotRange -> {All, All, {0, 50}}, Background -> Black, Boxed -> False, ImageSize -> 200];
pic2[t_] :=
Graphics3D[{posts, oposts, White}, PlotRange -> {All, All, {0, 50}},
Background -> Black, Boxed -> False, ViewVector -> viewvector[t]];
Manipulate[{pic1[t], pic2[t]}, {t, 0, 2 Pi}]


• The assignment of viewvector[t] should be :=. Commented Sep 20, 2014 at 1:32
• @evanb It is also correct that use Set. Commented Sep 20, 2014 at 9:25

Following the suggestions from the nice guys here, I finally figured out how to get the game started:

R = 20; pR = 30; oR = 40; highRng = {20, 50}; t = 0;
posts = Table[{Hue[RandomReal[]],
Cylinder[{{R Cos[ang], R Sin[ang], 0}, {R Cos[ang], R Sin[ang],
RandomInteger[highRng]}}]}, {ang, 0, 2 Pi, Pi/12}];

oposts = Table[{Hue[RandomReal[]],
Cylinder[{{oR Cos[ang], oR Sin[ang], 0}, {oR Cos[ang],
oR Sin[ang], RandomInteger[highRng]}}]}, {ang, 0, 2 Pi, Pi/12}];

im = Import["https://www.dropbox.com/s/7knvl519hg3s6qp/plane-4.obj?dl=1"][[1]];

Dynamic[Refresh[t = t + 0.1;
Graphics3D[{posts, oposts, White,
Translate[
Rotate[im, t, {0, 0, 1}], {pR Cos[t], pR Sin[t], 20 + Sin[t]}]},
PlotRange -> {All, All, {0, 50}},
Background -> Black,
Boxed -> False,
ViewVector -> {
BlockRandom[{pR Cos[t - RandomReal[{0.5, 0.9}]],
pR Sin[t - RandomReal[{0.5, 0.9}]] ,
80 RandomReal[{0.1, 1}]}], {pR Cos[t], pR Sin[t], 20 + Sin[t]}}
],
UpdateInterval -> 0.1],
TrackedSymbols -> {}
]