Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Linear zoom.

(or terragen steady cam, as Tim O' would put it ;) )

In order to achieve the sense of linnear zoom I decided to use a constant camera movement to get an example curve. With some basic trigonometry I was able to keep the FOV at the target point constant while camera-target distance increased.

The first thing to do is to interpret the FOV distance complex as a triangle. Then I had to calculate the initial values in order to achieve the whole range of zoom values for the distance change.

now in order to use trigonmetry I had to divide the original triangle in two smaller ones (with a 90º angle). Now we can calculate the alpha angle from our zoom value:

FOV = 2 x arctan (1/Zoom)
(alpha angle = FOV/2)

so in numbers: 2 x arctan (1.414) = 1.23 (radians)

Now we need to calculate the base (which will be a constant)

TAN(ALPHA) x hieght (height = camera-target distance)

in numbers: TAN(0.615) x 58 = 41.018 (in TG units)


We'll keep the base as a constant and well calculate the zoom change based on the ditance (height) and that constant base value. For this example I've decided to make my animation 60 frames long, during which my camera will travel a total distance of 150 TG units (an increment of 2.5 TG units per frame).

Frame 1

Frame 30

Frame 60

Now the math for this is fairy simple for each of the following frames:

TAN(alpha) = (base/heigt)

and then we convert this FOV into a TG zoom factor:

zoom = 1 / TAN (alpha)

This all gives the effect of "dolly zoom" (thanks to nathan williams for pointing this!).

 

All of this is pretty nice, but how do we apply this to get a linear zoom?

Well, using this method we could obtain a base/zoom curve:


So, in order to get the apereance of a linear zoom, the zoom values should follow a curve of this type. To obtain this curve we'll follow the inverse path to get zoom values. So now we'll keep distance as a constant and we are going to make base (or width) smaller (or larger for the case) in constant steps:


Now, with distance as a constant we should re-think the formulas:

ALPHA = ARCTAN ( BASE VARIABLE/ DISTANCE CONSTANT)
ZOOM = 1 / TAN(ALPHA)

So now we can "reduce" the width of our picture in, let's say 2 TG units per frame (at target distance), which is actually linear but as things get closer you might get the impression that it is zooming faster.

Using this approach, although the zoom is linear it is perceptually accelerating, an effect known as the "bungee effect". In order to deal with this we’re going to make a little change in the base width calculation: Instead of increasing or decreasing it in constant steps in TG units (eg. two at the time) we’re going to increase it or decrease it in a constant percentage from the last frame:

Frame 1: base = 160
Frame 2: base = 160 – (2% of 160) = 147.2
Frame 3: base = 147.2 – (2% of 147.2) = 135.2
Frame 4: base = 135.2 – (2% of 135.2) = 124.6
And so on…

This not only gives a better impression of linearity but also has the advantage of enabling as to make an infinite zoom, because the base value will decrease in ever smaller steps but will never reach 0, although we should take into account that the max zoom value within TG is 256, I don't know if via script it can be even higher...

If you want to calculate the linear zoom starting from initial and final zoom values first you'll have to convert them into initial and final base values, then decide the number of frames and keep the increments constant, wheather you decide to use the first or second approach.

 

Special Note:
Just to make this understandable I’ve only moved things in one axis (in this case “X”) keeping the target and camera heights at the same level and at the same line in the "Y" axis. This makes calculating the distance easier, if they are at different heights and "Y" points you’ll have to triangulate all other axis in order to get the distance. All other variables remain the same.

In order to calculate this the eqaton is as follows:


Special thanks to Luciana Larocca (My *almost* wife) for her help with trigonometry!
2003 ea-brc web
!