PDA

View Full Version : 2014 Calculating viewpoints for smooth orbit animations



apitcher799568
2014-04-09, 04:39 PM
I'm not sure if anyone ever has or already does anything like this (or if there's a better way), but I figured it couldn't hurt to post and share this.

When I first started doing Navisworks animations in college (3 years ago), the only advice I could find on how to create a smooth orbit around a model was to get a bunch of different viewpoints from roughly the same orbit or record an orbit and pick out viewpoints from the animation until I got some that looked good enough. That worked ok, but my orbits were always choppy. This stems from the fact that Navisworks moves the camera and focus point in a linear fashion from one viewpoint to the next. You need tons and tons of different points to make a curve, and simply capturing a bunch of different viewpoints that are kind of close will never get you viewpoints that all exist along the same orbital path (line on a sphere). The camera bounces up and down or turns sharply going between different positions, or speeds up or slows down no matter how much time you put in. It annoys the **** out of me, but almost everyone else's animations do the same things, so it's never been a big deal. Well, a few weeks ago I couldn't take it anymore and finally decided to do something about it.


Knowing that viewpoints are nothing but stored camera positions, focus points, and some speeds/angles, I decided that I could simply calculate the necessary points along the orbital path while maintaining the same focus point in order to create a super smooth circular orbit. Then, I could manually edit/create viewpoints with the necessary camera positions. A few hours of Wikipedia research and Excel work later, I did just that.


Step 1 - Find a start and end position. This is easy enough. Find a good view to start from, and save it. Then orbit to where you want to go and save that viewpoint.

Step 2 - Do some figuring. Using the positions of the camera in points 1 and 2, calculate the radius from the focus point and the xy-plane (phi) and z (theta) angles from the focus point based on an imaginary x, y, z, axis at the focus point (an imaginary user coordinate system using the focus point of the camera as its origin). This takes some fairly basic trigonometry adjusted for doing things in three dimensions.

Use these:

x1pos-x1lookat=x1r
y1pos-y1lookat=y1r
z1pos-z1lookat=z1r

x2pos-x2lookat=x2r
y2pos-y2lookat=y2r
z2pos-z2lookat=z2r

spherical radius (r)=sqr(xr12+yr12+zr12)

theta1=arcocos(z1r/r)
phi1=arctan(y1r/xr1r)

theta2=arcocos(z2r/r)
phi2=arctan(y2r/x2r)

thetadelta=theta2-theta1
phidelta=phi2-phi1



Step 3 - Figure out how many points you want to use. Shooting for the moon, I went with ~20, so that every point was at 5% intervals along the orbital path. These points all need to be equidistant along the orbital path so the same travel/angularspeed can be used for all the viewpoints. Multiply the percentage of the orbital path the point is on by the x, y, z angles between your start and end points to get the necessary angle between your first point and the desired point. Knowing these angles, the initial angles from the origin based on our start point, and our orbital radius, we can then calculate the x, y, and z positions along the orbit. Of course, you will need to make some corrections since your origin is probably not at 0,0,0. Since these calculations will all be the same, and the only thing that will change is the percentage along the orbital path of your point, all you need to do is make a list of percentages to use (5, 10, 15, 20, etc) and drag the formulas in Excel to get the necessary coordinates for your camera positions.

Use these:

lpoint (orbital location or percentage of orbital path) = 1/(n+1) (n being the number of desired viewpoints)

thetapoint=theta1+thetadelta*lpoint
phipoint=phi1+phidelta*lpoint

xpoint=r*sin(thetapoint)*cos(phipoint)
ypoint=r*sin(thetapoint)*sin(phipoint)
zpoint=r*cos(thetapoint)

xactual=xlookat-xpoint
yactual=ylookat-ypoint
zactual=zlookat+zpoint

(The point the camera is looking at is used for the correction because it is the origin/center of the orbit. To move the entire orbit, we transpose all of its o=points based on the origins coordinates)



Step 4 - Create a bunch of viewpoints and copy in all of your information. Add them all into an animation and watch the magic happen.

Step 5 - Use the API to create a plug in that will prompt you for the start and finish viewpoints and the number of desired viewpoints and handle all of these calculations to automatically create and populate the necessary viewpoints. (I haven't gotten here yet, but one day...)



Another interesting part of this is zooming in as you orbit. In my initial orbit, I used a static orbital radius. Well, if your radius is increasing or decreasing in relation to your position along your path, you can zoom in and out as you orbit. The calculation change is pretty simple. When you're calculating your positions (using your radius), simply multiply the radius by a zoom factor that increases or decreases based on which point you're calculating (5% along the path would be a 99% zoom, 10% would be a 98% zoom, 15% would be a 97% zoom, etc.). This would give you a kind of spiral orbit. You could also do something like this with your z position to make your camera raise and lower as it spirals (you'd end up with a path resembling a line drawn on a cone).