# How to animate 3-D figure using sequence of data [closed]

I have four points in 3-D, I want to join the points with a line. The points move with time. So I want to animate the jointed Point in three dimensions. I try to use ListAnimate and Graphics function. But I failed.

For example: The initial point positions are {0,0,0},{1,0,0},{2,0,0},{3,0,0}. Then they move with time. I store the position of the four points with table. But I could not join the points in 3-D. And also failed to animate them.

I used the Manipulate like this:

 Manipulate[
Graphics3D[{Thick, Line[gan],
VertexColors -> {Red, Green}}], {{number, 1}, 3, 1}]


with:

gan = {{cx1[[number]], cy1[[number]], cz1[[number]]}, {cx2[[number]],
cy2[[number]], cz2[[number]]}, {cx3[[number]], cy3[[number]],
cz3[[number]]}, {cx4[[number]], cy4[[number]], cz4[[number]]}};
cx1={{1,2,2,2,2,3,3,3,4,4,4}}
cx2={{1,2,2,2,2,3,3,3,4,4,4}}
cx3={{1,2,2,2,2,3,3,3,4,4,4}}
cx4={{1,2,2,2,2,3,3,3,4,4,4}}
cy1={{1,2,2,2,2,3,3,3,4,4,4}}
cy2={{1,2,2,2,2,3,3,3,4,4,4}}
cy3={{1,2,2,2,2,3,3,3,4,4,4}}
cy4={{1,2,2,2,2,3,3,3,4,4,4}}
cz1={{1,2,2,2,2,3,3,3,4,4,4}}
cz2={{1,2,2,2,2,3,3,3,4,4,4}}
cz3={{1,2,2,2,2,3,3,3,4,4,4}}
cz4={{1,2,2,2,2,3,3,3,4,4,4}}


but it gives an error.

-

## closed as unclear what you're asking by bobthechemist, Michael E2, István Zachar, Artes, PickettJan 13 at 10:52

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

Could you show what you have tried? –  Sjoerd C. de Vries Jan 8 at 13:42
I don't understand what gan and the subsequent symbols are supposed to do. –  bobthechemist Jan 8 at 14:20
Bad example that? Each point is the same, so you don't really have a line at all. Anyway, in addition to the two answers so far you might want to look into MapThread for easier syntax. –  Pickett Jan 8 at 16:50

I think you're trying to do something like this:

gan[number__] := {{cx1[[number]], cy1[[number]], cz1[[number]]}, {cx2[[number]],
cy2[[number]], cz2[[number]]}, {cx3[[number]], cy3[[number]],
cz3[[number]]}, {cx4[[number]], cy4[[number]], cz4[[number]]}};

Manipulate[
Graphics3D[{Thickness[0.1], Line[gan[1, number]], VertexColors -> {Red, Green}},
Axes -> True, PlotRange -> {{0, 4}, {0, 4}, {0, 4}}], {{number, 1}, 3, 1, 1}]


Things to note:

• I made gan a function so that Part coordinates as easily and correctly passed

• When I used the gan function I included the argument 1 because all of your coordinate lists have an extra nested List head

• I restricted values of the Manipulate parameter number to whole numbers by using the specification {{number, 1}, 3, 1, 1}

• I added a fixed PlotRange so that the motion of a point would be visible

-

pt1 = Transpose[Flatten[{cx1, cy1, cz1}, 1]];
pt2 = Transpose[Flatten[{cx2, cy2, cz2}, 1]] + .4;
pt3 = Transpose[Flatten[{cx3, cy3, cz3}, 1]] + .8;
pt4 = Transpose[Flatten[{cx4, cy4, cz4}, 1]] + .12;
ptseries = Transpose[{pt1, pt2, pt3, pt4}];


I added some offset to make it looks like line, and I believe you use VertexColors option for your line:

Manipulate[
Graphics3D[{Thickness[0.01],
Line[ptseries[[number]],
VertexColors -> {Red, Blue, Orange, Green}]}, Axes -> True,
PlotRange -> {{0, 4}, {0, 4}, {0, 4}}], {{number, 1}, 1, 10, 1}]

-

If I read the words and ignore the code, I come up with something like this:

Four points that depend on time:

p1[t_] := {t, 2-t, Cos[t]}; (* sample formula *)
p2[t_] := ...               (* user to supply the formulas *)
p3[t_] := ...
p4[t_] :=


The frames of animation:

animation = Table[
Graphics3D[{Line[{p1[time], p2[time], p3[time], p4[time]}]}],
{time, start, end, dt}];  (* user to supply values for start, end, dt *)


Animating the frames:

ListAnimate[animation]

-