3
$\begingroup$

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

enter image description here

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 -> {}
 ]
$\endgroup$
  • 1
    $\begingroup$ Related: (3528), (5649) $\endgroup$ – Mr.Wizard Sep 19 '14 at 10:49
  • $\begingroup$ And perhaps 14480 $\endgroup$ – Sjoerd C. de Vries Sep 19 '14 at 11:48
  • $\begingroup$ 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 $\endgroup$ – gst Sep 19 '14 at 13:08
  • $\begingroup$ Since you are moving in a circle you could of course use the the angular unit vector of your polar coordinates. $\endgroup$ – gst Sep 19 '14 at 13:21
  • $\begingroup$ See also: Slide 7 in Vitaly Kaurov's Mastering Dynamic Visualizations $\endgroup$ – kglr Sep 19 '14 at 18:14
3
$\begingroup$
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}]

enter image description here

$\endgroup$
  • $\begingroup$ The assignment of viewvector[t] should be :=. $\endgroup$ – evanb Sep 20 '14 at 1:32
  • $\begingroup$ @evanb It is also correct that use Set. $\endgroup$ – Apple Sep 20 '14 at 9:25
2
$\begingroup$

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

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.