Smooth zoom formula

805 Views Asked by At

I recently tried to find a way to zoom into an image with a smooth animation. When my initial scale is $1$ and is rising up to $1000$, a zoom from $10$ to $20$ has a higher graphical impact than a zoom from $20$ to $30$. I found this excellent formula to calculate a smooth zoom here, but the author didn't really tell me what it was.

$k=e^{ln(\frac{endvalue}{startvalue}) * iterations^{-1}}$

Each time calculating the formula, the previous zoom gets multiplied by that formula. I don't know why this gives me a smooth zoom, because I am not a mathematician, but I hope you can help me. Thanks in advance.

Zoom calculated 1 to 20, 5 iterations with said formula:

1 / 1.82 / 3.31 / 6.03 / 10.99 / 20 > "smooth zoom"

1

There are 1 best solutions below

0
On BEST ANSWER

Make the zoom-factor such that, from image to image, you are zooming by the same factor. This means you want a geometric progression of zooms, not an arithmetic one.

More specific, if you want to achieve a zoom factor of $Z$ in $N$ steps, then you need to perform $N$ zooms where each one has a relative zomm factor of $$F=Z^{1/N}$$ Relative to the initial size, the zoom factors will be $$1=Z^{0/N}, Z^{1/N}, Z^{2/N}, \ldots, Z^{N/N}= Z$$

For example, if you want to zoom from 1 to 1000 in 100 steps, each step will zoom by a relative factor of $$ F = 1000^{1/100} \approx 1.0715 = 107.15\%$$ and you reached the "half way" at 50 steps and a zoom factor of $\sqrt{1000}\approx 31.62$.

If you are given two zoom factors $F_1$ and $F_2$ and want to determine the proportion of $F_1\cdots F_2$ relative to the final zoom $Z$, that proportion is given by $$P_Z(F_1, F_2) = \frac{\ln F_2 - \ln F_1}{\ln Z} = \frac{\ln (F_2/F_1)}{\ln Z}$$

For example, if you have a 1000-fold zoom, then $$P_{1000}(20,10) \approx 0.100 = 10\%$$ but $$P_{1000}(30,20) \approx 0.059 = 5.9\%$$ where the %-value refers to the progress of the zooming process. And that's exactly what you experienced: Zomming from 10× to 20× is more than zooming from 20× to 30×.