i want to rotate and scale the image on multi touch event, i am able to drag, scale the image but i can't understand the rotation of image. i am facing problem so please help me asap. my code is there

    public class Touch extends Activity implements OnTouchListener {
       private static final String TAG = "Touch";
      // These matrices will be used to move and zoom image
       Matrix matrix = new Matrix();
   Matrix matrix1 = new Matrix();
   Matrix savedMatrix = new Matrix();
   Matrix savedMatrix2 = new Matrix();
   // We can be in one of these 3 states
   static final int NONE = 0;
   static final int DRAG = 1;
   static final int ZOOM = 2;
   int mode = NONE;
   float oldscale =0;
   // Remember some things for zooming
   PointF start = new PointF();
   PointF mid = new PointF();
   float oldDist = 1f;

   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      ImageView view = (ImageView) findViewById(R.id.imageView2);
      view.setOnTouchListener(this);

      ImageView view1 = (ImageView) findViewById(R.id.imageView2);
      view1.setOnTouchListener(this);

      // ...
      // Work around a Cupcake bug
      matrix.setTranslate(1f, 1f);
      matrix1.setTranslate(1f, 1f);
      view.setImageMatrix(matrix);
      view1.setImageMatrix(matrix1);
   }

   @Override
   public boolean onTouch(View v, MotionEvent rawEvent) {
      WrapMotionEvent event = WrapMotionEvent.wrap(rawEvent);
      // ...
      ImageView view = (ImageView) v;

      // Dump touch event to log
       dumpEvent(event);

      // Handle touch events here...
       double r = Math.atan2(event.getX() - 400 / 2,
            400 / 2 - event.getY());
       int rotation = (int) Math.toDegrees(r);
       float newRot = new Float(rotation);

      switch (event.getAction() & MotionEvent.ACTION_MASK) {

      case MotionEvent.ACTION_DOWN:
         savedMatrix.set(matrix);
    
Edit
Report