2
$\begingroup$

I have a list of data that I interpolate (Omega[t]) and animate - it is working fine, but an Integrate over the InterpolationFunction (Omega[t]) and then animating it doesn't work.

Any suggestions ?

CODE:

data = {150, 148, 145, 144, 143, 80, -80, -81, -82, -83};
Omega = Interpolation[data, InterpolationOrder -> 4]; 
Plot[Omega[t], {t, 1, 10}]

Animate[Graphics3D[{Cuboid[{-20, -20, -1.01}, {20, 20, -1}], 
                    GeometricTransformation[{Green, Tube[{{0, 0, 0}, {0, 0, 0.15}}, 
                         {1.25, 0}], 
                         Cylinder[{{0, 0, 0}, {0, 0, 1}}, 1/4],
                         Blue, Cylinder[{{0, 0, 0}, {0, 1, 0}}, 1/4]}, 
                         RotationTransform[Omega[t], {0, 0, 1}]]},
               Boxed -> False, SphericalRegion -> True, PlotRange -> 3,  
               PlotRange -> 3],
     {t, 1, 10, 0.04}, AnimationRunning -> False, SaveDefinitions -> True]

And my object spins, but after this

OmegaIntegrate = Evaluate@Integrate[Omega[t], t];
Plot[OmegaIntegrate, {t, 1, 10}]

and then

 Animate[Graphics3D[{Cuboid[{-20, -20, -1.01}, {20, 20, -1}], 
                GeometricTransformation[{Green, Tube[{{0, 0, 0}, {0, 0, 0.15}}, {1.25, 0}], 
                     Cylinder[{{0, 0, 0}, {0, 0, 1}}, 1/4], 
                     Blue, Cylinder[{{0, 0, 0}, {0, 1, 0}}, 1/4]}, 
                RotationTransform[OmegaIntegrate[t], {0, 0, 1}]]}, 
           Boxed -> False, SphericalRegion -> True, PlotRange -> 3, 
           PlotRange -> 3],
      {t, 1, 10, 0.04}, AnimationRunning -> False, SaveDefinitions -> True]
$\endgroup$
1
  • 1
    $\begingroup$ The link to your file doesn't work, also this is not the preferred way of sharing your code. You should include the code in your post. $\endgroup$
    – C. E.
    May 22, 2015 at 15:04

1 Answer 1

1
$\begingroup$
data = {150, 148, 145, 144, 143, 80, -80, -81, -82, -83};
omega = Interpolation[data, InterpolationOrder -> 4]; 

omegaIntegrate := Integrate[omega[s], s]; 

Animate[Graphics3D[{Cuboid[{-20, -20, -1.01}, {20, 20, -1}], 
    GeometricTransformation[{Green, Tube[{{0, 0, 0}, {0, 0, 0.15}}, {1.25, 0}], 
      Cylinder[{{0, 0, 0}, {0, 0, 1}}, 1/4], Blue, Cylinder[{{0, 0, 0}, {0, 1, 0}}, 1/4]}, 
     RotationTransform[omegaIntegrate, {0, 0, 1}]]}, Boxed -> False, 
   SphericalRegion -> True, PlotRange -> 3, PlotRange -> 3] /. s -> t, 
{t, 1, 10, 0.04}, AnimationRunning -> False, 
 SaveDefinitions -> True]

enter image description here

$\endgroup$
2
  • $\begingroup$ Such a simple solution and I struggled with a few hours.THX. $\endgroup$ May 22, 2015 at 16:14
  • $\begingroup$ @Mariusz, my pleasure. Thanks for the accept. $\endgroup$
    – kglr
    May 22, 2015 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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