2
$\begingroup$

With the following code

A = {{2.53237`, -1.39681`, 1.75671`}, {2.89875`, -0.411846`, 1.69636`}, 
     {2.89008`, -0.12331`, 1.75562`}, {3.01636`, 0.369294`, 1.48836`}, 
     {2.92773`, 0.985344`, 1.38112`}, {2.37448`, 2.07486`, 1.22752`}, 
     {1.59398`, 2.61631`, 1.43672`}, {0.810986`, 2.93926`, 1.46732`}, 
     {-0.417625`, 3.02086`, 1.46629`}, {-2.03506`, 2.17147`,1.61036`}, 
     {-2.91503`, 0.562121`, 1.62377`}, {-3.14816`, -0.441141`, 1.15952`}, 
     {-2.85433`, -1.66821`, 0.721034`}, {-1.88754`, -2.54601`, 1.18532`}, 
     {0.0116145`, -3.00769`, 1.55038`}, {0.999672`, -2.88571`, 1.45717`}, 
     {2.27014`, -2.12282`,1.33795`}, {2.39526`, -1.82074`, 1.54843`}, 
     {2.20699`, -2.14913`, 1.40016`}};

frames = 
  Table[
     ParametricPlot3D[{t, t, t}, {t, -5, 5}, ViewPoint -> A[[a]]], 
     {a, 1, Length[A]}];

Export["trial.gif", frames, "AnimationRepetitions" -> ∞, "DisplayDurations" -> 1];

I get

enter image description here

where I matched the matrix A beforehand as recommended here.

What I would like to do now is to write an A-like matrix using a function so that the base plane is always horizontal and rotation is more homogeneous. The problem is that I have no idea what function to write. Ideas?

$\endgroup$
  • 1
    $\begingroup$ You might be interested in this. $\endgroup$ – J. M. will be back soon Sep 18 '17 at 15:53
  • $\begingroup$ @J.M. I just think you've centered on the problem. I read it calmly and then I'm alive again. For now thank you. $\endgroup$ – TeM Sep 18 '17 at 16:05
  • 1
    $\begingroup$ Why not $a[\theta] = \{ 5 \cos (\theta), 5 \sin (\theta), 5 \}$? This keeps the $z$ height constant and rotates the viewpoint in a circle. $\endgroup$ – David G. Stork Sep 18 '17 at 17:27
5
$\begingroup$

enter image description here

You are using ViewPoint and if you would read docs thoroughly you'd see just the example you need in Applications section. The only thing I added is AnimationRate->.01 that makes it very smooth.

http://reference.wolfram.com/language/ref/ViewPoint.html

Animate[
    With[
        {v=RotationTransform[θ,{0,0,1}][{3,0,3}]},
        Row[{
            Graphics3D[{
                    Sphere[],Cuboid[],Red,PointSize[Large],
                    Point[v],Line[{v,{0,0,0}}],FaceForm[],
                    EdgeForm[Black],Cuboid[{-1,-1,-1},{1,1,1}]},
                PlotRange->3,BoxStyle->Gray,ImageSize->300],

            Graphics3D[{Sphere[],Cuboid[]},
                ViewPoint->v,SphericalRegion->True,ImageSize->300]}]],

{θ,0,2Pi},AnimationRunning->False,AnimationRate->.01]

To make GIF replace Animate with Table with small enough step to make GIF smooth (see top image):

frames=Table[
    With[
        {v=RotationTransform[θ,{0,0,1}][{3,0,3}]},
        Row[{
            Graphics3D[{
                    Sphere[],Cuboid[],Red,PointSize[Large],
                    Point[v],Line[{v,{0,0,0}}],FaceForm[],
                    EdgeForm[Black],Cuboid[{-1,-1,-1},{1,1,1}]},
                PlotRange->3,BoxStyle->Gray,ImageSize->300],

            Graphics3D[{Sphere[],Cuboid[]},
                ViewPoint->v,SphericalRegion->True,ImageSize->300]}]],

{θ,0,2Pi,.1}];

Export["frames.gif",frames] 
$\endgroup$
  • $\begingroup$ Now everything is back, thank you all! =) $\endgroup$ – TeM Sep 18 '17 at 23:06

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.