TouchPoint &p2 = points[1];
float ddx = p.down_x-p2.down_x;
float ddy = p.down_y-p2.down_y;
- if(p.x*p2.x+p.y*p2.y<0 && (p.x*ddx+p.y*ddy)*(p2.x*ddx+p2.y*ddy)<0)
- /* If the points moved in different directions and also both away from
- or towards the other, it's a pinch gesture. */
+ float away = p.x*ddx+p.y*ddy;
+ float turn = p.y*ddx-p.x*ddy;
+ float away2 = -(p2.x*ddx+p2.y*ddy);
+ float turn2 = -(p2.y*ddx-p2.x*ddy);
+ if(away*away2>0 && abs(away)>abs(turn) && abs(away2)>abs(turn2))
+ /* If the points moved away from or towards each other without rotating
+ significantly, it's a pinch gesture. */
current_gesture = GESTURE_PINCH;
else
invalid_gesture = true;