title: Touch move gesture logic...how to determine direction of movement in 2d?
body: <p>How can i determine the direction of gesture ? The use case is shown in the image link. what is the right logic for detecting in which direction the person is trying to move the ball in the circular path ? I have called the direction method in move gesture...Can someone help me fine tune this ... ?</p>
  
  <p><a href="http://www.shrenikvikam.com/wp-content/uploads/2011/04/214e422a43E11S3.png-150x134.png" rel="nofollow">http://www.shrenikvikam.com/wp-content/uploads/2011/04/214e422a43E11S3.png-150x134.png</a></p>
  
  <pre><code>     private String getDirection(float firstTouchX, float finalTouchX){
          if((firstTouchX - finalTouchX)>0)
              return "Left";
          else
              return "Right";
      }
  
  
      @Override
      public boolean onTouchEvent(MotionEvent event) {
          int action = event.getAction();
  
          switch (action) {
              // MotionEvent class constant signifying a finger-down event
              case MotionEvent.ACTION_DOWN: {
                  Log.d("ACTION DOWN","Value ->");
                  final float x = event.getX();
                  final float y = event.getY();
                  initialTouchX = x;
                  initialTouchY = y;
                  break;
  
              }
              // MotionEvent class constant signifying a finger-drag event
              case MotionEvent.ACTION_MOVE: {
                  final float x = event.getX();
                  final float y = event.getY();
                  final String direction = getDirection(initialTouchX,x);
                  Log.d("ACTION MOVE","diff in initial and cur value of x  ->" + direction + (initialTouchX - x) + initialTouchX + "y->" + initialTouchY);
  
                  break;
  
              }
              // MotionEvent class constant signifying a finger-up event
              case MotionEvent.ACTION_UP: {
                  Log.d("ACTION UP","Value ->");
  
                  break;
              }
          }
          return true;
      }</code></pre>