# Animating an InterpolationFunction and its integral

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]

• 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. May 22, 2015 at 15:04

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]


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