Simple multi-touch gesture Algorithm

Source: Internet
Author: User


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.








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.