"Continuous" change of viewpoint from 2D to 3D view

I want to create a sequence of 3D plots so that a polygon lying in the plane z=0 is initially viewed from above (so that it looks like a 2D plot) and in the end from the standard viewpoint. I tried to do this with the following code.

drawpoly[u_List, v_List, n_, viewpoint_List] := Graphics3D[{Black,Line[Table[Cos[2*Pi/n*i]*u + Sin[2*Pi/n*i]*v, {i, 0, n}]]},PlotRange -> {{-1.25, 1.25}, {-1.25, 1.25}, {-1.25, 1.25}},Boxed -> False, ViewPoint ->viewpoint];

n = 6;
m = 10;

u = {1, 0, 0};
v = {0, 1, 0};

Table[drawpoly[u, v, 6, (1 - j/m)*{0, 0, 2} + j/m*{1.3, -2.4, 2}], {j,0, m}]



Notice that there is a "discontinuous" jump between the first two images. How do I "continuously" change to the standard viewpoint {1.3,-2.4,2} from the 2D "above viewpoint"?

• If I understand what you mean by "discontinuous" jump, Table[drawpoly[...,Normalize[(1 - j/m)*{0, 0, 2} + j/m*{1.3, -2.4, 2}],...] seems to fix it. Commented Dec 2, 2021 at 13:15
• @N.J.Evans Many thanks, but I don't think it does. If you compare the second and third image in the series, they are only slightly different. Whereas the first and second "differ" by a rotation of almost 30 degrees. So there is a jump from 1 to 2 and then things behave "continuously". I hope this clarifies my issue. Commented Dec 2, 2021 at 13:41
• {j,1, m} ? Why we need j start from 0? Commented Dec 2, 2021 at 14:03
• I see what you mean - the orientation of the polygon in it's plane seems to change discontinuously. I'm guessing that ViewPoint alone might not be powerful enough for what you want to do. There is likely some confusion about how to handle where the top of the camera should face when you are oriented along the vertical which resolves as soon as you move away from the vertical. AddingViewVertical->{-1.3, 2.4, 2} to drawpoly gets rid of this problem - but might not be the actual setting you want. Commented Dec 2, 2021 at 15:05
• Many thanks! It does indeed resolve the problem, but also introduces a new one. Now things look bad at the end of the sequence. Commented Dec 2, 2021 at 15:32

It looks like the camera is getting confused because your initial view point is parallel to the default 'ViewVertical' in the first frame and so a default orientation is chosen, after the first frame the camera orients to the z-axis.

One way to handle this is to explicitly pick a ViewVertical that produces the desired orientation, e.g.

drawpoly[u_List, v_List, n_, viewpoint_List] :=
Graphics3D[{Black,
Line[Table[Cos[2*Pi/n*i]*u + Sin[2*Pi/n*i]*v, {i, 0, n}]]},
PlotRange -> {{-1.25, 1.25}, {-1.25, 1.25}, {-1.25, 1.25}},
Boxed -> False, ViewPoint -> viewpoint, ViewVertical->{-1.3,2.4,2.0},Axes -> True, AxesOrigin -> {0, 0, 0}];


Where I've chosen a vector rotated around the z-axis from your final view point - (x,y,z)->(-x,-y,z). If you use a vector that is parallel to any of your view points the frame with that view point will get confused. If you wanted to go all around the image, for instance, you'd have to either pick a vector in the plane of rotation that isn't one of your viewpoints, or calculate a new vector for each frame to make sure you don't run into the same artifact.

• That makes sense, many thanks! Commented Dec 2, 2021 at 21:34