I thought of using the two-finger gesture on the iPad to zoom in and out and move parallel to the screen.

At first, I implemented β€œthe amount of shift of the center of gravity of two fingers as parallel shift and the ratio of increase or decrease of the distance between fingers as scaling,” but this is not correct.

How is it incorrect? Let o1 and o2 be the touch start positions and p1 and p2 be the current touch positions. For example, suppose you shrink your finger by 1/2 while keeping the center of gravity at the edge of the screen. (4, 0), (4, 4) β†’ (4, 1), (4, 3) In this case, the above formula would shrink by 1/2 without parallel shift. It is wrong whether it is to the origin or to the center of the screen. It needs to contract against the center of gravity of the two fingers. image

Now, if we describe the deformation f in general as β€œx, y parallel shift after s times with respect to the origin”, what happens to this s, x, y, respectively?

would be ideal, but is not feasible for some touch movements because the deformation does not include rotation. So we minimize . ( least-squares method )

Differentiate E by s, x, and y, respectively, and set it to 0. Organize Eq. Substituting this for the derivative in s and never organizing x and y gives the formula for s.

Reference: Differentiation in s

  • image

It is easy to show that this is different from β€œthe shift of the center of gravity of two fingers as a parallel shift and the ratio of increase or decrease of the distance between the fingers as a scaling. image For example, a move like this would be about 0.7x in the type that uses the increase or decrease in finger spacing as the magnification factor. But if we try to minimize the error under the condition of β€œno rotation”, it is correct to multiply by 0.5. The above formula can be properly answered as β€œmultiply by 0.5 and move (2, 1)β€œ. image


This page is auto-translated from /nishio/δΊŒζœ¬ζŒ‡γ‚Έγ‚§γ‚Ήγƒγƒ£γ§γ‚ΊγƒΌγƒ γ¨εΉ³θ‘Œη§»ε‹• using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I’m very happy to spread my thought to non-Japanese readers.