[quote]

if(vms<30){ // why 30? i thought it should be 60 minutes?

[/quote]

ctam=Math.atan2(mx,my);

vm=(int)(ctam/pi2*T);

The angle is zero degree when value for minute is 15.

The angle for minute=0 is 30 degree.

if(vms<30)vh--;// counterclockwise rotating so hour value decrease by 1: vh-- is the same as vh=vh-1;

else if(vms>30)vh++;// clockwise rotating so hour value increase by 1: vh++ is the same as vh=vh+1;

if(Math.abs(vm-vms)>40.){// this is related to how fast user drag it, the value was found by try and error (I think)