How to Increase Speed of Cube on finger touch in Android OpenGL?
<p>I am working on an Android application in which I am facing a problem regarding rotation  of 3D Cube.
   .
        I want to rotate my cube according to fingure touch.
         -If User Touch Fast speed on mobile screen then cube should be move fast and
          stop slowly -2 after some time .
         - And if user Touch slowly then cube should be move slowly.</p>

<p>Till Now I have tried this code which is not working--
   for rotation--
                //Rotate around the axis based on the rotation matrix (rotation, x, y, z)
        gl.glRotatef(PhotoCube3DLWPActivity.xrot, 1.0f, 0.0f, 0.0f);    //X
        gl.glRotatef(PhotoCube3DLWPActivity.yrot, 0.0f, 1.0f, 0.0f);    //Y
        gl.glRotatef(PhotoCube3DLWPActivity.zrot, 0.0f, 0.0f, 1.0f);    //Z</p>

<pre><code>    cube.draw(gl);                  //Draw the Cube 

    //Change rotation factors (nice rotation)
    PhotoCube3DLWPActivity.xrot +=0.3f;;
    PhotoCube3DLWPActivity.yrot +=0.2f;
    PhotoCube3DLWPActivity.zrot +=0.4f;
</code></pre>

<p>where xrot,yrot and zrot are static variable of PhotoCube3DLWPActivity class which values are 0.3f,0.2f and 0.4f respectiblly.</p>

<p>for Touch event I am using-
         @Override
        public void onTouchEvent(MotionEvent event) {
            super.onTouchEvent(event);
            switch (event.getAction()) {</p>

<pre><code>            case MotionEvent.ACTION_DOWN :
                Log.i("check", "Hey action down");
                downX = event.getX();
                downY = event.getY();
                downTime = System.currentTimeMillis();
                break;
            case MotionEvent.ACTION_MOVE :
                // handle in between rotation

                break;

            case MotionEvent.ACTION_UP :
                Log.i("check", "Hey action up");
                diffX = event.getX() - downX;
                diffY = event.getY() - downY;
                diffTime = System.currentTimeMillis() - downTime;

                diffTouch = (float) Math.sqrt(diffX * diffX + diffY * diffY);

                diffSpeed = diffTouch / diffTime * 1.0f;

                diffAngle = (float) Math.atan(diffY / diffX);

                xrot += diffSpeed * Math.sin(diffAngle);
                yrot += diffSpeed * Math.cos(diffAngle);

                break;
        }

    }//touch end
</code></pre>
