Simple multi-touch gesture Algorithm
1. Zoom action
1) detected dual-finger
Down event. The distance between the two fingers is
olddistant;
2) calculate the distance between two fingers in real time when the two fingers move
sampledistant;
3) Calculate the scaling ratio:
zoom
= sampledistant / olddistant;
4) Repeat
2,
Step 3
An up event occurs.
2. Rotate action
1) detect dual-finger
Down event, record the dual-finger coordinate at this time
X coordinate and
The Y coordinate difference and the distance between the two fingers are recorded
olddisx,olddisy,olddistant;
2) When the double finger is moved, the distance between the two points is recorded.
distant,disx,disy.
3) If
Olddistant and
The distant value is close,
Disx, DISY, and
The value of olddisx and olddisy varies greatly.
Rotate action,
Rotate angle
DISY/disx, and
The ratio of olddisy to olddisx is determined.
4) duplicate
2)
3) Two steps
The up event ends the calculation.